edu.columbia.cs.cs1007.checkers
Class Square

java.lang.Object
  extended by edu.columbia.cs.cs1007.checkers.Square

public class Square
extends java.lang.Object

This class implements a square of the checkers board. It contains both the color of the square, and any pieces that may have been placed onto that square.

Author:
Julia Stoyanovich (jds2109@columbia.edu) COMS 1007, Summer 2009.

Constructor Summary
Square(Constants.SQUARE_COLOR color)
          Constructor that creates a square with an "empty" piece.
Square(Constants.SQUARE_COLOR color, Piece contents)
          Constructor.
 
Method Summary
 Constants.SQUARE_COLOR getColor()
          Accessor.
 Piece getContents()
          Accessor.
 boolean isOccupied()
          Check whether there is a non-empty piece on this square.
 void removeContents()
          Replace the contents of the square by an "empty" piece.
 void setContents(Piece contents)
          Place a piece onto the square.
 java.lang.String toString()
          Generate a string representation of the square.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Square

public Square(Constants.SQUARE_COLOR color)
Constructor that creates a square with an "empty" piece.

Parameters:
color -

Square

public Square(Constants.SQUARE_COLOR color,
              Piece contents)
Constructor.

Parameters:
color -
contents -
Method Detail

getColor

public Constants.SQUARE_COLOR getColor()
Accessor.

Returns:
square color

getContents

public Piece getContents()
Accessor.

Returns:
piece that is positioned onto the square.

setContents

public void setContents(Piece contents)
Place a piece onto the square.

Parameters:
contents -

removeContents

public void removeContents()
Replace the contents of the square by an "empty" piece.


isOccupied

public boolean isOccupied()
Check whether there is a non-empty piece on this square.

Returns:
true if there is a piece there, false othewise

toString

public java.lang.String toString()
Generate a string representation of the square.

Overrides:
toString in class java.lang.Object
Returns:
string