|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.rice.comp440.Backgammon
This class wraps all of the backgammon functionality. Basically, the use model for this class is build a new Backgammon with two players, execute backgammon.run(), which runs the game, and the call backgammon.reset(), backgammon.run() if you want to play again.
Field Summary | |
protected Board |
board
|
protected Dice |
dice
|
protected int |
player
|
protected Player[] |
players
|
Constructor Summary | |
Backgammon(Player player1,
Player player2)
Builds a new backgammon instance, given the two players to play the game between. |
Method Summary | |
Board |
getCurrentBoard()
Returns the current board. |
int |
getCurrentPlayer()
Returns the current player, either Board.BLACK or Board.WHITE |
Dice |
getDice()
Returns the current dice |
Move[] |
getMoves()
Returns a list of all of the possible moves which the player can currently make |
boolean |
isGameOver()
Returns whether or not the game is over |
void |
print(java.io.PrintStream out)
Prints out a gnubg-style text board. |
void |
print(java.io.PrintStream out,
Board board)
Prints out a gnubg-style text board. |
void |
reset()
Resets this backgammon instance to the initial state, with a new board and the black player's move |
Player |
run()
Runs a game of backgammon, and does not return until the game is over. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected Board board
protected Dice dice
protected int player
protected Player[] players
Constructor Detail |
public Backgammon(Player player1, Player player2)
player1
- The first player (BLACK)player2
- The second player (WHITE)Method Detail |
public Player run()
public void reset()
public int getCurrentPlayer()
public Move[] getMoves()
public Dice getDice()
public Board getCurrentBoard()
public boolean isGameOver()
public void print(java.io.PrintStream out)
out
- The output stream to write the board topublic void print(java.io.PrintStream out, Board board)
out
- The output stream to write the board toboard
- The board
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |