public interface Ship
extends java.io.Serializable
Modifier and Type | Method and Description |
---|---|
boolean |
containsPosition(Point2d point)
Returns
true if this ship contains a point specified by the
parameter. |
java.util.List<Point2d> |
getAllPositions()
Gets all points used by this ship.
|
java.util.List<Point2d> |
getProjectionPoints(Point2d point)
Returns temporary projection points of the ship determined by the point
given in the input.
|
int |
getSize()
Returns the size of the current ship.
|
java.util.Optional<Point2d> |
getStartingPosition()
Gets the starting position of this ship.
|
boolean |
isPlaced()
Returns
true if this ship was placed. |
boolean |
isSunk()
Returns
true if the ship was sunk. |
void |
place(Point2d startingPosition)
Places a ship where specified with standard Direction
(EAST).
|
void |
place(Point2d startingPosition,
ShipDirection direction)
Places a ship where specified.
|
void |
resetPlacement()
Resets the placement of this ship.
|
boolean |
shoot(Shot shot)
Tries to shoot this ship.
|
void |
switchDirection(ShipDirection direction)
Switches the direction of the ship if possible.
|
boolean containsPosition(Point2d point)
true
if this ship contains a point specified by the
parameter.point
- Point2d
true
if this ship contains the specified pointvoid place(Point2d startingPosition, ShipDirection direction)
startingPosition
- Point2d
direction
- ShipDirection
void place(Point2d startingPosition)
startingPosition
- Point2d
void resetPlacement()
boolean shoot(Shot shot)
true
if the ship was hit,
false
otherwise.shot
- Shot
true
if the ship was hit, false
otherwisejava.util.List<Point2d> getAllPositions()
boolean isPlaced()
true
if this ship was placed.true
if this ship was placedjava.util.Optional<Point2d> getStartingPosition()
java.util.List<Point2d> getProjectionPoints(Point2d point)
point
- point where the ship will startPoint2d
int getSize()
boolean isSunk()
true
if the ship was sunk.true
if the ship was sunkvoid switchDirection(ShipDirection direction)
direction
- ShipDirection