edu.rice.comp440.move
Class Move

java.lang.Object
  |
  +--edu.rice.comp440.move.Move

public class Move
extends java.lang.Object

Class which represents a move in backgammon. Clients can either build specific moves themselves, possibly from human input, or use the movement factory to build moves. Moves are constructed by adding a number of movements until all of the dice have been used or no more moves are possible. When evalutaing a move, a client can use the move.getCurrentBoard() method, which will return the state of the board after the move.


Field Summary
protected  Board board
           
protected  Board[] boards
           
protected  Dice dice
           
protected  Movement[] movements
           
protected  int player
           
protected  int[] used
           
static int USED
           
 
Constructor Summary
Move(Dice dice, Board board, int player)
          Builds a new Move, using the provided dice roll
Move(Move move)
          Clones the given move
 
Method Summary
 void addMovement(Movement movement)
          Adds a movement to this move.
 boolean equals(java.lang.Object other)
          Returns whether or not this move is equal to the other
 Board getCurrentBoard()
          Returns the current scratch board, or the board with all internmediate movements applied
protected  int getNumMovements()
          Returns the number of movements currently in this move
 Board getOriginalBoard()
          Returns the starting board of the move
 int hashCode()
          Returns the hashCode of this move
 boolean isFull()
          Returns whether or not there are move moves to be made
 boolean movePossible()
          Returns whether or not a move is possible for the current user.
 java.lang.String toString()
          Returns a String representation of this move
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

USED

public static int USED

dice

protected Dice dice

movements

protected Movement[] movements

used

protected int[] used

board

protected Board board

boards

protected Board[] boards

player

protected int player
Constructor Detail

Move

public Move(Dice dice,
            Board board,
            int player)
Builds a new Move, using the provided dice roll
Parameters:
dice - The dice roll

Move

public Move(Move move)
Clones the given move
Parameters:
move - The move to clone
Method Detail

movePossible

public boolean movePossible()
Returns whether or not a move is possible for the current user.
Parameters:
player - The current player
Returns:
Whether or not a move is possible for the user

addMovement

public void addMovement(Movement movement)
                 throws IllegalMoveException
Adds a movement to this move.
Parameters:
movement - The movement ot add

getCurrentBoard

public Board getCurrentBoard()
Returns the current scratch board, or the board with all internmediate movements applied
Returns:
the current scratch board

getOriginalBoard

public Board getOriginalBoard()
Returns the starting board of the move
Returns:
The starting board

isFull

public boolean isFull()
Returns whether or not there are move moves to be made
Returns:
Whether or not there are more moves

getNumMovements

protected int getNumMovements()
Returns the number of movements currently in this move
Returns:
The number of movements in this move

hashCode

public int hashCode()
Returns the hashCode of this move
Overrides:
hashCode in class java.lang.Object
Returns:
the hasCode of the final board

equals

public boolean equals(java.lang.Object other)
Returns whether or not this move is equal to the other
Overrides:
equals in class java.lang.Object
Parameters:
other - TO come to
Returns:
Whether or not they are eqaul

toString

public java.lang.String toString()
Returns a String representation of this move
Overrides:
toString in class java.lang.Object
Returns:
a String