Package battleship.model.game.ocean
Class Ocean
java.lang.Object
battleship.model.game.ocean.Ocean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetPointsOccupiedByShip
(Ship attackingShip) get list of points which is occupied by shipgetShipByPosition
(Point pos) int
int
boolean
static Ocean
randomPlace
(List<Ship> ships, Ocean ocean) Random place list of shipstryPlaceShip
(Ship shipToPlace, ShipPosition shipPosition) if it is impossible to place ship, method returns null; if possible -> place ship on position
-
Constructor Details
-
Ocean
- Throws:
IllegalArgumentException
-
-
Method Details
-
getSizeHorizontal
public int getSizeHorizontal()- Returns:
- horizontal size of the ocean
-
getSizeVertical
public int getSizeVertical()- Returns:
- vertical size of the ocean
-
randomPlace
Random place list of ships- Parameters:
ships
- list of ships to placeocean
- ocean on which ships needs to be placed- Returns:
- Ocean
-
isEmpty
- Parameters:
pos
- position to check- Returns:
- true if it is empty, otherwise false.
-
getShipByPosition
- Parameters:
pos
- position- Returns:
- Ship on position, if position is out of ocean or empty return null
-
tryPlaceShip
if it is impossible to place ship, method returns null; if possible -> place ship on position- Parameters:
shipToPlace
- ship to placeshipPosition
- position- Returns:
- ShipPosition
-
getPointsOccupiedByShip
get list of points which is occupied by ship- Parameters:
attackingShip
- ship- Returns:
- list of points
-