|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--AbstractBoardGame
AbstractBoardGame implements common methods to TicTacToe and Gomoku
Field Summary | |
protected int |
_cols
|
protected char[][] |
_gameState
|
protected Player[] |
_player
|
protected int |
_rows
|
protected int |
_squaresLeft
|
protected int |
_turn
|
protected Player |
_winner
|
protected int |
_winningScore
|
Constructor Summary | |
AbstractBoardGame()
|
Method Summary | |
protected void |
assert(boolean assertion)
|
protected void |
checkWinner(int col,
int row)
New algorithm needed for larger boards. |
Player |
currentPlayer()
|
char |
get(int col,
int row)
Needed by Runner |
protected int |
getCol(java.lang.String coord)
|
protected int |
getRow(java.lang.String coord)
|
protected void |
init(int rows,
int cols,
int score,
Player playerX,
Player playerO)
Generic initialization for BoardGame. |
boolean |
inRange(int col,
int row)
|
void |
move(java.lang.String coord,
char mark)
Called by the current player during an update(). |
boolean |
notOver()
The game is not over as long as there is no winner and somebody can still make a move ... |
protected void |
set(int col,
int row,
char mark)
set() and get() translate between chess coordinates and array indices. |
protected void |
setWinner(char player)
Look up which player is the winner, and set _winner accordingly. |
int |
squaresLeft()
|
protected void |
swapTurn()
|
void |
test()
Some generic tests for both TicTacToe and Gomoku. |
java.lang.String |
toString()
A plain ascii representation of the game, mainly for debugging purposes. |
void |
update()
Ask the current player to make a move. |
Player |
winner()
|
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
protected char[][] _gameState
protected int _rows
protected int _cols
protected int _winningScore
protected Player _winner
protected Player[] _player
protected int _turn
protected int _squaresLeft
Constructor Detail |
public AbstractBoardGame()
Method Detail |
protected void init(int rows, int cols, int score, Player playerX, Player playerO)
protected void set(int col, int row, char mark) throws AssertionException
public char get(int col, int row) throws AssertionException
public void update() throws java.io.IOException
public Player currentPlayer()
public void move(java.lang.String coord, char mark) throws AssertionException
protected int getCol(java.lang.String coord) throws AssertionException
protected int getRow(java.lang.String coord) throws AssertionException
protected void swapTurn()
public Player winner()
public boolean notOver()
public int squaresLeft()
protected void checkWinner(int col, int row) throws AssertionException
protected void setWinner(char player)
public java.lang.String toString()
public boolean inRange(int col, int row)
protected void assert(boolean assertion) throws AssertionException
public void test()
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |