Class Board

java.lang.Object
  extended by Board

public class Board
extends java.lang.Object

This class represents the board on which checkers is being played. The board holds a collection of pieces.

Author:

Field Summary
static int KING
           
static int SINGLE
           
 
Constructor Summary
Board()
          This constructor creates a new board at the beginning of the game
 
Method Summary
 java.util.Vector bluePieces()
          This method returns a vector containing all blue Pieces
 java.awt.Color colorAt(int space)
          This method returns the color of the piece at a certain space
 Piece getPieceAt(int space)
          This method returns the piece at the certain position
 boolean hasPieceOf(java.awt.Color color)
          This method returns if there is a piece of color on the board
 void kingPiece(int space)
          This method creates a king piece
 int movePiece(int start, int end)
          Move the piece at the start position to the end position
 boolean occupied(int space)
          This method checks if the space on the board contains a piece
 void removePiece(int space)
          This method removes piece at the position space
 int sizeOf()
          This method returns the size of the board
 java.util.Vector whitePieces()
          This method returns a vector containing all white Pieces
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SINGLE

public static int SINGLE

KING

public static int KING
Constructor Detail

Board

public Board()
This constructor creates a new board at the beginning of the game

Method Detail

movePiece

public int movePiece(int start,
                     int end)
Move the piece at the start position to the end position

Parameters:
start - - current location of the piece
end - - the position where piece is moved
Returns:
-1 if there is a piece in the end position

occupied

public boolean occupied(int space)
This method checks if the space on the board contains a piece

Parameters:
space - - the space that needs to be checked
Returns:
true or false depending on the situation

removePiece

public void removePiece(int space)
This method removes piece at the position space

Parameters:
space - - the positon of the piece to be removed

kingPiece

public void kingPiece(int space)
This method creates a king piece

Parameters:
space - - the psotion at which the king piece is created

colorAt

public java.awt.Color colorAt(int space)
This method returns the color of the piece at a certain space

Parameters:
space - - the position of the piece on the board
Returns:
the color of this piece

getPieceAt

public Piece getPieceAt(int space)
This method returns the piece at the certain position

Parameters:
space - - the space of the piece
Returns:
the piece at that space

hasPieceOf

public boolean hasPieceOf(java.awt.Color color)
This method returns if there is a piece of color on the board

Parameters:
color - - the color of the piece
Returns:
true if there is a piece of color left on the board else return false

sizeOf

public int sizeOf()
This method returns the size of the board

Returns:
the size of the board, always 64

bluePieces

public java.util.Vector bluePieces()
This method returns a vector containing all blue Pieces

Returns:
blue pieces on the board

whitePieces

public java.util.Vector whitePieces()
This method returns a vector containing all white Pieces

Returns:
white pieces on the board