checkers.model
Class Rules

java.lang.Object
  extended by checkers.model.Rules
All Implemented Interfaces:
CheckersConstants
Direct Known Subclasses:
ForceJumpValidator

public class Rules
extends java.lang.Object
implements CheckersConstants

This class is used to check the validity of the moves made by the players. It also checks to see if the conditions for the end of the game have been met.

Author:
,

Field Summary
 
Fields inherited from interface checkers.CheckersConstants
ACCEPT, BLUE, CLIENTGAME, DRAW, HOST, HOSTGAME, JOIN, KING, LOCAL, LOCALGAME, NUM_SPACES, PLAYER1SET, PLAYER2SET, RESIGN, SINGLE, UPDATE, WHITE
 
Method Summary
static Rules getInstance()
          getInstance Creates the singleton instance of the Rules object
 int getJumpIndex()
          getJumpIndex get the index of the jumped piece
 boolean isJump(int start, int end)
          isJump Checks to see if the move is a valid jump
 void setBoard(Board theBoard)
          setBoard Sets the board
 boolean validateMove(Move move)
          This method checks to see if the move that was just made was valid and returns a boolean indicating that.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static Rules getInstance()
getInstance Creates the singleton instance of the Rules object

Returns:
the Rules object

setBoard

public void setBoard(Board theBoard)
setBoard Sets the board

Parameters:
theBoard - the checker board

validateMove

public boolean validateMove(Move move)
This method checks to see if the move that was just made was valid and returns a boolean indicating that.

Parameters:
move - The move that is to be validated.
Returns:
Boolean indicating if it was valid.

isJump

public boolean isJump(int start,
                      int end)
isJump Checks to see if the move is a valid jump

Parameters:
start - the start position of the given move
end - the end position of the given move
Returns:
returns true if the move is a valid jump

getJumpIndex

public int getJumpIndex()
getJumpIndex get the index of the jumped piece

Returns:
the index of the jumped piece