Class Ocean

java.lang.Object
battleship.model.game.ocean.Ocean

public class Ocean extends Object
  • Constructor Details

  • Method Details

    • getSizeHorizontal

      public int getSizeHorizontal()
      Returns:
      horizontal size of the ocean
    • getSizeVertical

      public int getSizeVertical()
      Returns:
      vertical size of the ocean
    • randomPlace

      public static Ocean randomPlace(List<Ship> ships, Ocean ocean)
      Random place list of ships
      Parameters:
      ships - list of ships to place
      ocean - ocean on which ships needs to be placed
      Returns:
      Ocean
    • isEmpty

      public boolean isEmpty(Point pos)
      Parameters:
      pos - position to check
      Returns:
      true if it is empty, otherwise false.
    • getShipByPosition

      public Ship getShipByPosition(Point pos)
      Parameters:
      pos - position
      Returns:
      Ship on position, if position is out of ocean or empty return null
    • tryPlaceShip

      public ShipPosition tryPlaceShip(Ship shipToPlace, ShipPosition shipPosition)
      if it is impossible to place ship, method returns null; if possible -> place ship on position
      Parameters:
      shipToPlace - ship to place
      shipPosition - position
      Returns:
      ShipPosition
    • getPointsOccupiedByShip

      public List<Point> getPointsOccupiedByShip(Ship attackingShip)
      get list of points which is occupied by ship
      Parameters:
      attackingShip - ship
      Returns:
      list of points