Class EmptySea


public class EmptySea extends Ship
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 Smith
  • Constructor Details

    • EmptySea

      public EmptySea()
      Sets the inherited length variable and initializes the hit 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.
      Overrides:
      shootAt in class Ship
      Parameters:
      row - the row of the shot
      column - the column of the shot
      Returns:
      false always, since nothing will be hit.
    • isSunk

      public boolean isSunk()
      Since an EmptySea is empty by definition, it is not possible that one can be sunk.
      Overrides:
      isSunk in class Ship
      Returns:
      false always, since nothing will be hit.
    • toString

      public String toString()
      Returns a single character String to use in the Ocean's print method. 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. Since an EmptySea is empty by definition, targeting it will always result in a miss so return "-".
      Overrides:
      toString in class Ship
      Returns:
      "-" always, since nothing will be hit
    • getShipType

      public String getShipType()
      Specified by:
      getShipType in class Ship
      Returns:
      "empty", indicating that this is an Empty sea tile.