Package battleship
Interface IPosition
- All Known Implementing Classes:
Position
public interface IPosition
The interface Position.
- Author:
- fba
-
Method Summary
Modifier and TypeMethodDescriptionRetrieves a list of positions that are adjacent to the current position.booleanEquals boolean.intGets traditional column.charGets traditional row.intGets column.intgetRow()Gets row.booleanisAdjacentTo(IPosition other) Is adjacent to boolean.booleanisHit()Is hit boolean.booleanisInside()Checks if the position is inside the board.booleanIs occupied boolean.voidoccupy()Occupy.voidshoot()Shoot.
-
Method Details
-
getRow
int getRow()Gets row.- Returns:
- the row
-
getColumn
int getColumn()Gets column.- Returns:
- the column
-
getClassicRow
char getClassicRow()Gets traditional row.- Returns:
- the traditional row within [A-J]
-
getClassicColumn
int getClassicColumn()Gets traditional column.- Returns:
- the traditional column within [1-10]
-
equals
Equals boolean. -
isInside
boolean isInside()Checks if the position is inside the board.- Returns:
- true if the position is inside the board, false otherwise
-
isAdjacentTo
Is adjacent to boolean.- Parameters:
other- the other- Returns:
- the boolean
-
occupy
void occupy()Occupy. -
shoot
void shoot()Shoot. -
isOccupied
boolean isOccupied()Is occupied boolean.- Returns:
- the boolean
-
isHit
boolean isHit()Is hit boolean.- Returns:
- the boolean
-
adjacentPositions
Retrieves a list of positions that are adjacent to the current position. Adjacent positions are defined as those sharing a border or corner with the current position.- Returns:
- a list of adjacent positions as IPosition objects
-