|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
The abstract representation of a game. A board keeps track of a stack of
moves and changes its internal state as moves are pushed and
popped from the stack. The board is also responsible for keeping track of
the players that are playing the game and the order in which they take turns.
This software is for educational purposes only.
| Method Summary | |
IPiece[][] |
getBoard()
|
String |
getDescription()
|
IPlayer[] |
getPlayers()
|
String |
getShortDescription()
|
int |
getState()
|
IPlayer |
getWinner()
|
Iterator |
moveIterator()
|
void |
moves(Collection col)
Populates the specified Collection with the set of all
currently legal moves. |
IMove |
peekMove()
|
Iterator |
playerIterator()
|
IMove |
popMove()
Removes the last move from this board's stack. |
void |
pushMove(IMove move)
Adds the specified move to this board's stack. |
void |
pushMove(String strMove)
Translates the specified String into a move and then
adds that move onto this board's stack. |
void |
resetState()
Returns this board to its initial state so it will be ready for a new game. |
void |
setPlayers(IPlayer[] players)
Specifies the players that will be playing this game. |
| Method Detail |
public IPiece[][] getBoard()
public void pushMove(String strMove)
throws StateException
move and then
adds that move onto this board's stack.
strMove - a string representation of a move. A move is created
based on this string, and that move will be added to the stack.
StateException - if the specified move string could not be
translated into an IMove object, or the move is illegal.
public void pushMove(IMove move)
throws StateException
move to this board's stack.
StateException - if the specified move is illegal.
public IMove popMove()
throws StateException
move from this board's stack.
StateException - if the stack is empty.
public IMove peekMove()
throws StateException
StateException - if the stack is empty.
public void setPlayers(IPlayer[] players)
throws StateException
players that will be playing this game.
players - an array of players that will be playing
the game.
StateException - if the specified number of type of players cannot
play this game.public IPlayer[] getPlayers()
public Iterator playerIterator()
Iterator of the players currently
playing this game. The players will be iterated in the order in which
they are allowed to take their turns. The iterator will be empty if
this game has ended.public IPlayer getWinner()
player that has won this game, or
null if there is currently no winner, or if this game
has ended in a tie.public int getState()
public void resetState()
public Iterator moveIterator()
Iterator of the set of all
currently legal moves.public void moves(Collection col)
Collection with the set of all
currently legal moves.
col - the Collection that will be populated with the set of
all currently legal moves.public String getDescription()
public String getShortDescription()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||