Class GomokuCell
java.lang.Object
GomokuCell
This class is cell of the board of the Gomoku game.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate EnumMap<Cardinal, GomokuCell> Enumerate neighbor with key in Cardinal direction and key representing the cell in that direction.private ColorThe state of the cell represented by the enumerate Color, Nil is empty, white and black for the color of a token -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturn neighbours.getNeighbour(Cardinal car) Return one neighbour.Return the number of same colored neighbours in all direction.getState()Return the state.booleanisEmpty()This method returns if the current cell is emptybooleanReturn if the cell is playable.booleanisPlayed()This method returns if the cell has already played.static voidlink(GomokuCell c1, GomokuCell c2, Cardinal c1Toc2) voidlinkCell(Cardinal car, GomokuCell cell) This method link the cell at the Cardinal position on the current cell.voidChange state of the current cell.toString()
-
Field Details
-
neighbour
Enumerate neighbor with key in Cardinal direction and key representing the cell in that direction. -
state
The state of the cell represented by the enumerate Color, Nil is empty, white and black for the color of a token
-
-
Constructor Details
-
GomokuCell
The constructor of the cell.- Parameters:
state- The state by default of the cell.
-
-
Method Details
-
getNeighbour
Return one neighbour.- Parameters:
car- The Cardinal direction.- Returns:
- The GomokuCell at the direction.
-
getAllNeighbour
Return neighbours.- Returns:
- The EnumMap of neighbours.
-
getSameColorNeighbour
-
getState
-
setState
Change state of the current cell.- Parameters:
c- The color of the token played.- Throws:
IllegalStateException- If the cell is not playable.
-
isEmpty
public boolean isEmpty()This method returns if the current cell is empty- Returns:
- True if is empty, False if is not.
-
isPlayed
public boolean isPlayed()This method returns if the cell has already played.- Returns:
- True if the cell is already played, False if is not.
-
isPlayable
public boolean isPlayable()Return if the cell is playable.- Returns:
- True if the current cell can be played with the condition of the gomoku.
-
linkCell
This method link the cell at the Cardinal position on the current cell.- Parameters:
car- The Cardinal direction of the cell to link.cell- The GomokuCell to link.
-
link
-
toString
-