public class TicTacToeGame
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private FieldState[] |
board
The board.
|
private int |
turnCount
The turn count.
|
| Constructor and Description |
|---|
TicTacToeGame()
Instantiates a new tic tac toe game.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
calcWinner(int[] turns)
Calculate the winner and the turn in which the winning move was made and returns it.
|
private int |
convertFieldIDToColumn(int fieldID)
Convert field id to column.
|
private int |
convertFieldIDToRow(int fieldID)
Convert field id to row.
|
private FieldState |
gameWinner(int lastTurn)
Determines if the game in it's current state has a winner.
|
private FieldState[] |
initFieldStateArray(int size)
Initializes the field state array.
|
private boolean |
isFirstPlayersTurn()
Checks if it is first players turn.
|
private void |
makeTurn(int fieldID)
Makes turn.
|
private FieldState[] board
private int turnCount
public java.lang.String calcWinner(int[] turns)
turns - all turns that were made in the gameprivate FieldState gameWinner(int lastTurn)
lastTurn - the field occupied with last turnprivate int convertFieldIDToRow(int fieldID)
fieldID - the field idprivate int convertFieldIDToColumn(int fieldID)
fieldID - the field idprivate void makeTurn(int fieldID)
fieldID - the ID of the field that should be occupiedprivate boolean isFirstPlayersTurn()
private FieldState[] initFieldStateArray(int size)
size - the size