# Class GomokuCell

java.lang.Object
GomokuCell

public class GomokuCell extends Object
This class is cell of the board of the Gomoku game.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `private EnumMap<Cardinal, GomokuCell>`
  `neighbour`
  Enumerate neighbor with key in Cardinal direction and key representing the cell in that direction.
  `private Color`
  `state`
  The state of the cell represented by the enumerate Color, Nil is empty, white and black for the color of a token

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GomokuCell(Color state)`
  The constructor of the cell.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `EnumMap<Cardinal, GomokuCell>`
  `getAllNeighbour()`
  Return neighbours.
  `GomokuCell`
  `getNeighbour(Cardinal car)`
  Return one neighbour.
  `Map<Cardinal,Integer>`
  `getSameColorNeighbour()`
  Return the number of same colored neighbours in all direction.
  `Color`
  `getState()`
  Return the state.
  `boolean`
  `isEmpty()`
  This method returns if the current cell is empty
  `boolean`
  `isPlayable()`
  Return if the cell is playable.
  `boolean`
  `isPlayed()`
  This method returns if the cell has already played.
  `static void`
  `link(GomokuCell c1, GomokuCell c2, Cardinal c1Toc2)`
  `void`
  `linkCell(Cardinal car, GomokuCell cell)`
  This method link the cell at the Cardinal position on the current cell.
  `void`
  `setState(Color c)`
  Change state of the current cell.
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### neighbour

    private EnumMap<Cardinal, GomokuCell> neighbour
    Enumerate neighbor with key in Cardinal direction and key representing the cell in that direction.

  - ### state

    private Color 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

    public GomokuCell(Color state)
    The constructor of the cell.
    Parameters:
      `state` - The state by default of the cell.

- ## Method Details

  - ### getNeighbour

    public GomokuCell getNeighbour(Cardinal car)
    Return one neighbour.
    Parameters:
      `car` - The Cardinal direction.
    Returns:
      The GomokuCell at the direction.

  - ### getAllNeighbour

    public EnumMap<Cardinal, GomokuCell> getAllNeighbour()
    Return neighbours.
    Returns:
      The EnumMap of neighbours.

  - ### getSameColorNeighbour

    public Map<Cardinal,Integer> getSameColorNeighbour()
    Return the number of same colored neighbours in all direction.
    Returns:
      The Map of neighbours.

  - ### getState

    public Color getState()
    Return the state.
    Returns:
      The state of the current cell with one Color.

  - ### setState

    public void setState(Color c)
    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

    public void linkCell(Cardinal car, GomokuCell cell)
    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

    public static void link(GomokuCell c1, GomokuCell c2, Cardinal c1Toc2)

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`