Class CheckerBoard

java.lang.Object
  |
  +--CheckerBoard

public class CheckerBoard
extends java.lang.Object

This class defines a CheckerBoard. and provides several methods for manipulating them. A CheckerBoard has one field, board, which is an array of Positions.


Field Summary
 Position[] board
           
 
Constructor Summary
CheckerBoard()
          Initializes the CheckerBoard, setting all pieces to empty 'e'.
CheckerBoard(java.lang.String s)
          Initializes the CheckerBoard by using the board defintion from the server to set the pieces.
 
Method Summary
static CheckerBoard Copy(CheckerBoard b)
          Given a CheckerBoard, returns a copy.
 boolean isEmpty(int i)
          Returns true if the piece at position i is 'e'.
 char Piece(int i)
          Given a board position number, returns the piece at that location.
 void PrintBoard()
          Prints the Checkerboard in a format that is easy to understand by people
 void SetPiece(int i, char c)
          Set the piece at position i to be c.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

board

public Position[] board
Constructor Detail

CheckerBoard

public CheckerBoard()
Initializes the CheckerBoard, setting all pieces to empty 'e'.


CheckerBoard

public CheckerBoard(java.lang.String s)
Initializes the CheckerBoard by using the board defintion from the server to set the pieces. A piece can be either 'p', 'P', 'o', 'O', or 'e'. (player, player king, opponent, opponent king, or empty)

Method Detail

Piece

public char Piece(int i)
Given a board position number, returns the piece at that location.


isEmpty

public boolean isEmpty(int i)
Returns true if the piece at position i is 'e'. True otherwise.


SetPiece

public void SetPiece(int i,
                     char c)
Set the piece at position i to be c. While c should be one of 'p', 'P', 'o', 'O', 'e', the method does not check for this.


PrintBoard

public void PrintBoard()
Prints the Checkerboard in a format that is easy to understand by people


Copy

public static CheckerBoard Copy(CheckerBoard b)
Given a CheckerBoard, returns a copy.