|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--WhiteBlackGame
|
+--TicTacToeGame
Tic-Tac-Toe Game:
A TicTacToeGame object controls the execution of
a game of tic-tac-toe.
| Field Summary | |
protected static java.lang.String |
BLACK_LABEL
|
protected static java.lang.String |
WHITE_LABEL
|
| Constructor Summary | |
TicTacToeGame()
Constructs a game for 2 players, "O" and "X". |
|
| Method Summary | |
protected boolean |
allInARow(int firstRow,
int firstCol,
int beyondLastRow,
int beyondLastCol,
int rowIncrement,
int colIncrement)
Returns true if all of the cells in a row, column, or diagonal have been filled by the same player; false otherwise. |
boolean |
blackWon()
Returns true if the simulation is over black won; false otherwise. |
protected java.lang.String |
findWinner()
Looks for a winner and returns the label of the winner (or a null string if no winner found. |
boolean |
gameOver()
Returns true if the game is over; otherwise, returns false. |
protected java.lang.String |
labelAt(edu.kzoo.grid.Location loc)
Returns the label of the player at the specified location (or null if no player has marked the specified location). |
void |
startGame(edu.kzoo.grid.Grid grid)
Starts or restarts the application. |
boolean |
whiteWon()
Returns true if the simulation is over and white won; false otherwise. |
| Methods inherited from class WhiteBlackGame |
blackPlayer, getGrid, respondToMousePress, whitePlayer, whitesTurn |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected static final java.lang.String WHITE_LABEL
protected static final java.lang.String BLACK_LABEL
| Constructor Detail |
public TicTacToeGame()
| Method Detail |
public void startGame(edu.kzoo.grid.Grid grid)
startGame in class WhiteBlackGamepublic boolean gameOver()
gameOver in class WhiteBlackGamepublic boolean whiteWon()
whiteWon in class WhiteBlackGamepublic boolean blackWon()
protected java.lang.String findWinner()
protected boolean allInARow(int firstRow,
int firstCol,
int beyondLastRow,
int beyondLastCol,
int rowIncrement,
int colIncrement)
protected java.lang.String labelAt(edu.kzoo.grid.Location loc)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||