Class EmptySea
java.lang.Object
Ship
EmptySea
Considered a type of Ship so that the Ocean's ship 2D array can consist of
EmptySea references for empty tiles and proper ships for tiles with ships
actually inside of them.
- Author:
- harry
-
Field Summary
-
Constructor Summary
ConstructorDescriptionEmptySea()
Sets the inheritedlength
variable and initializes thehit
array, based on the size of this Empty Sea (1 tiles). -
Method Summary
Modifier and TypeMethodDescriptionboolean
isSunk()
Since an EmptySea is empty by definition, it is not possible that one can be sunk.boolean
shootAt
(int row, int column) Since an EmptySea is empty by definition, shooting at one will always be a miss.toString()
Returns a single character String to use in the Ocean's print method.Methods inherited from class Ship
getBowColumn, getBowRow, getLength, isHorizontal, okToPlaceShipAt, placeShipAt, setBowColumn, setBowRow, setHorizontal
-
Constructor Details
-
EmptySea
public EmptySea()Sets the inheritedlength
variable and initializes thehit
array, based on the size of this Empty Sea (1 tiles).
-
-
Method Details
-
shootAt
public boolean shootAt(int row, int column) Since an EmptySea is empty by definition, shooting at one will always be a miss. -
isSunk
public boolean isSunk()Since an EmptySea is empty by definition, it is not possible that one can be sunk. -
toString
Description copied from class:Ship
Returns a single character String to use in the Ocean's print method. This method should return "x" if the ship has been sunk, and "S" if it has not yet been sunk. This method can only be used to print out locations in the ocean that have been shot at; it should not be used to print locations that have not been the target of a shot yet. -
getShipType
- Specified by:
getShipType
in classShip
- Returns:
- "empty", indicating that this is an Empty sea tile.
-