public final class FieldImpl extends java.lang.Object implements Field
Modifier and Type | Method and Description |
---|---|
static FieldImpl |
createField(FieldBound fieldBound) |
boolean |
equals(java.lang.Object o) |
FieldBound |
getFieldBound()
Returns the boundary of the field.
|
FieldCell[][] |
getFieldCells()
Returns the field cells matrix.
|
int |
hashCode() |
boolean |
isShipPlaceable(Ship ship,
Point2d point)
Returns true if the ship is placeable.
|
void |
placeShip(Ship ship,
Point2d point)
Places a ship in the field with a standard direction (EAST).
|
void |
placeShip(Ship ship,
Point2d point,
ShipDirection direction)
Places a ship in the field.
|
java.lang.String |
toString() |
void |
updateStateWithShot(Shot shot)
Updates the field with a shot.
|
public static FieldImpl createField(FieldBound fieldBound)
public void placeShip(Ship ship, Point2d point, ShipDirection direction)
Field
public void placeShip(Ship ship, Point2d point)
Field
public void updateStateWithShot(Shot shot)
Field
updateStateWithShot
in interface Field
shot
- any kind of shot Shot
. It must be within
the boundary limit.public FieldBound getFieldBound()
Field
getFieldBound
in interface Field
public FieldCell[][] getFieldCells()
Field
getFieldCells
in interface Field
public boolean isShipPlaceable(Ship ship, Point2d point)
Field
isShipPlaceable
in interface Field
ship
- the current ship to placepoint
- position where the ship will start. It must be within
the boundary.true
if the ship is placeablepublic boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object