Class OthelloState

java.lang.Object
  extended byOthelloState

public class OthelloState
extends Object

Class used to represent the board during a game of Othello.

Version:
1.0
Author:
Matt Hoffman

Constructor Summary
OthelloState()
          Initialize the board.
 
Method Summary
 OthelloPiece at(int row, int col)
          Return the piece at the given (row,col).
 Object clone()
          Return a cloned copy of the state.
 OthelloPiece currentPlayer()
          Return the current player's color, as a OthelloPiece object.
 void forfeitMove()
          Forfeit the current turn.
 boolean gameOver()
          Return whether or not the game is over, ie neither Black nor White can make any more moves.
 boolean isValidMove(int row, int col)
          Return whether a placement at (row,col) is valid for the current player.
static boolean isValidPosition(int row, int col)
          See if the specified position is valid, in other words: it's on the board.
 void makeMove(int row, int col)
          Place a piece in the specified (row,col) position.
 OthelloPiece otherPlayer()
          Return the player who is not playing this turn.
 OthelloPiece winner()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OthelloState

public OthelloState()
Initialize the board.

Method Detail

clone

public Object clone()
Return a cloned copy of the state.


isValidPosition

public static boolean isValidPosition(int row,
                                      int col)
See if the specified position is valid, in other words: it's on the board.

Parameters:
row - The row of the move (0-7).
col - The column of the move (0-7).

currentPlayer

public OthelloPiece currentPlayer()
Return the current player's color, as a OthelloPiece object.


otherPlayer

public OthelloPiece otherPlayer()
Return the player who is not playing this turn.


gameOver

public boolean gameOver()
Return whether or not the game is over, ie neither Black nor White can make any more moves.


at

public OthelloPiece at(int row,
                       int col)
Return the piece at the given (row,col).

Parameters:
row - The row of the move (0-7).
col - The column of the move (0-7).

isValidMove

public boolean isValidMove(int row,
                           int col)
Return whether a placement at (row,col) is valid for the current player.

Parameters:
row - The row of the move (0-7).
col - The column of the move (0-7).

makeMove

public void makeMove(int row,
                     int col)
              throws InvalidMoveException
Place a piece in the specified (row,col) position. If the move is invalid, an InvalidMoveException will be thrown. This exception should not be caught by any of the players, and must instead be caught by the game itself.

Parameters:
row - The row of the move (0-7).
col - The column of the move (0-7).
Throws:
InvalidMoveException

winner

public OthelloPiece winner()

forfeitMove

public void forfeitMove()
                 throws InvalidMoveException
Forfeit the current turn. If there is no valid move to make, this will forfeit the current turn. However, if there is a valid move, this will throw an InvalidMoveException.

Throws:
InvalidMoveException