Package battleship.model.ships
Class Ship
java.lang.Object
battleship.model.ships.Ship
- Direct Known Subclasses:
Battleship
,Carrier
,Cruiser
,Destroyer
,Submarine
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvertInputIntegersToShips
(int[] counters) Converts input integers, where these numbers are listed in the order which corresponds to ship types size, to list of ships.abstract int
hitTheShip
(FiringMode firingMode) Hit the ship with firing mode.abstract void
When the recovery mode is enabled this method restore.
-
Field Details
-
health
protected int health
-
-
Constructor Details
-
Ship
protected Ship(int health)
-
-
Method Details
-
hitTheShip
Hit the ship with firing mode.- Parameters:
firingMode
- if TORPEDO_FIRING_MODE -> ship immediately get sunk. if GENERAL_FIRING_MODE -> health--.- Returns:
- healthReport with health remaining and power(health) of attack.
-
getLength
public abstract int getLength()- Returns:
- length of the ship (MAX_HEALTH = length).
-
restoreHealthInRecoveryMode
public abstract void restoreHealthInRecoveryMode()When the recovery mode is enabled this method restore. health of the ship to MAX_HEALTH (depends on the ship type). -
convertInputIntegersToShips
Converts input integers, where these numbers are listed in the order which corresponds to ship types size, to list of ships.- Parameters:
counters
- Array of integers.- Returns:
- List of the ships (sorted by length descending)
-