|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.game.AbstractGame
com.antelmann.game.ttt.TickTackToe
public class TickTackToe
This class implements the game TickTackToe.
The board positions are represented as follows:
0 1 2 3 4 5 6 7 8
| Constructor Summary | |
|---|---|
TickTackToe()
|
|
TickTackToe(String name)
|
|
| Method Summary | |
|---|---|
Object |
clone()
making sure that the internal non-primitive board representation is properly cloned to allow the deep-copy required for spawnChild() |
boolean |
equals(Object obj)
required to allow recognizing the same game status even after serialization (to support network games, GameBooks, etc.). |
int[] |
getWinner()
getWinner() is checking for a triple (three-in-a-row). |
int |
hashCode()
It's just some number derived from a portion of the board; not guaranteed to be unique for every game, but guaranteed to always be the same for the same board. |
protected GameMove[] |
listLegalMoves()
listLegalMoves() returns the legal moves for this game. |
int |
nextPlayer()
nextPlayer() returns the integer representing the game role of the next player. |
protected boolean |
popMove()
popMove undoes the last move by altering the game board to the stage before the last move happened. |
protected boolean |
pushMove(GameMove move)
pushMove takes a GameMove and alters the game according to to the move. |
String |
toString()
overridden to provide useful information about the game |
| Methods inherited from class com.antelmann.game.AbstractGame |
|---|
addObserver, clearRedoList, gameOver, getGameName, getLastMove, getLastPlayer, getLegalMoves, getLegalMoves, getMoveHistory, getNumberOfRedoMoves, getObservers, getRedoList, getResult, isLegalMove, isWinner, loadFromFile, makeMove, numberOfMoves, numberOfPlayers, redoMove, removeObserver, resetLegalMoves, resetLists, saveToFile, spawnChild, undoLastMove, undoMoves |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public TickTackToe()
public TickTackToe(String name)
| Method Detail |
|---|
public int nextPlayer()
GamePlay
public int[] getWinner()
protected GameMove[] listLegalMoves()
AbstractGame
listLegalMoves in class AbstractGameprotected boolean pushMove(GameMove move)
AbstractGame
pushMove in class AbstractGameprotected boolean popMove()
AbstractGame
popMove in class AbstractGamepublic String toString()
AbstractGame
toString in class AbstractGame
public Object clone()
throws CloneNotSupportedException
clone in interface GamePlayclone in class AbstractGameCloneNotSupportedExceptionAbstractGame.spawnChild(GameMove)public int hashCode()
hashCode in class Objectpublic boolean equals(Object obj)
equals in class Object
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||