0% found this document useful (0 votes)
18 views2 pages

StarWars Task

This document describes a starship simulation game with 3 types of starships - destroyers, transports, and ironclads. Each starship has properties of armor, shield, and number of guardsmen. The power of each ship type is calculated differently based on its properties: destroyers' power is half its shield, transports' power is its number of guardsmen, and ironclads' power is its armor. The document provides instructions to find the most powerful ship in the solar system and list all unprotected planets.

Uploaded by

canberk.arkose
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

StarWars Task

This document describes a starship simulation game with 3 types of starships - destroyers, transports, and ironclads. Each starship has properties of armor, shield, and number of guardsmen. The power of each ship type is calculated differently based on its properties: destroyers' power is half its shield, transports' power is its number of guardsmen, and ironclads' power is its armor. The document provides instructions to find the most powerful ship in the solar system and list all unprotected planets.

Uploaded by

canberk.arkose
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Star Wars

A starship has a name. If it protects a planet, the planet is also known. It has 3
properties: its armour (natural number), its shield (natural number), and the
number of guardsmen on the ship. There are 3 types of ship: the destroyer, the
transport, and the ironclad. The power of a ship depends on its type and its
properties:
• The destroyer’ power is given as the half of its shield.
• The transport’s power means the number of guardsmen on it.
• The ironclad’ power means its armour.

1. Find the ship with the greates power in the Solar System!
2. List all the unprotected planets!
3. Give the total shield of the ships guarding a given planet!
Star Wars 2nd component of p.MaxPower()

(l,(. ,max,ship), . ) = MAX p∊planets p.MaxPower()2 SolarSystem


p.MaxPower()1
return (l, ship) + SolarSystem() { creating planets }
return ⊕ <e> + MaxPowerShip() : bool×Starship {query}
e∊planets
e.ShipCount()=0 + Unprotected() : Planet {query}

+ planets
Starship if planet ≠ null then error endif *
# name : string planet := p Planet
# armour : int { getter p.Protect(this)
} - name : string
+ Planet( string) return |ships|
# shield : int * prot 0..1
# guards : int + ShipCount() : int ships.Add(s)
- ships # planet
+ Starship(string,int,int,int) + Protect(s:Starship)
+ Protect(p:Planet) + Leave(s:Starship) ships.Remove(s)
+ Leave() + TotalShield() : real {query}
+ Power() : real {virtual, query} + MaxPower() : bool×real×Starship {query}
if planet = null then error endif
planet.Leave(this) return MAX e.Power()
e∊ships
planet := null true
return ∑ e.GetShield()
e∊ships

Destroyer Transport Ironclad

+Power():real {override, query} +Power():real {override, query} +Power():real {override, query}


return shield/2 return guards return armour

You might also like