Class Rules

java.lang.Object
  |
  +--Rules

public class Rules
extends java.lang.Object

The Rules class is used to verify that players are playing by the rules for the game Tic Tac Toe. Bugs: none known


Constructor Summary
Rules()
           
 
Method Summary
static void checkMove(Move move, Board board)
          Checks if a specified move is valid for the specified board.
static void checkWin(Board board, Move move, Mark mark)
          Checks if a specified move results in a win for the specified mark on the board.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Rules

public Rules()
Method Detail

checkMove

public static void checkMove(Move move,
                             Board board)
Checks if a specified move is valid for the specified board. If the move isn't valid, an error message is displayed and the program is terminated.
Parameters:
move - the specified move to be checked
board - the specified board on which the move would be made

checkWin

public static void checkWin(Board board,
                            Move move,
                            Mark mark)
Checks if a specified move results in a win for the specified mark on the board. The row, column, and possibly a diagonal are checked for three of the player's marks "in a row". If there is a winner, the mark of the winner is displayed and the program is terminated.
Parameters:
move - the specified move where the checking is to be based
board - the board to be checked for a win
mark - the mark of the player that is to be checked for a win