Package battleship.model.game.ocean
Class ShipPosition
java.lang.Object
battleship.model.game.ocean.ShipPosition
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enum
All available direction -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ShipPosition
getRandomShipPosition
(Ocean ocean, Ship shipToPlace) Places the ship to random position with random direction.int
getX()
int
getY()
static ShipPosition.Direction
-
Constructor Details
-
ShipPosition
- Parameters:
pos
- point (x, y)direction
- direction
-
-
Method Details
-
randomDirection
- Returns:
- random direction.
-
getRandomShipPosition
Places the ship to random position with random direction.- Parameters:
ocean
- ocean on which to place the shipshipToPlace
- ship to place- Returns:
- null if it's impossible, otherwise ship position.
-
getX
public int getX()- Returns:
- x coordinate
-
getY
public int getY()- Returns:
- y coordinate
-
getPosition
- Returns:
- Point (x, y)
-
getDirection
- Returns:
- direction
-