Class Piece

java.lang.Object
  extended by Piece

public abstract class Piece
extends java.lang.Object

This class contains information and methods associated with the piece for a checker board public


Field Summary
protected  int checkerNumber
           
protected  java.awt.Color color
           
protected  java.awt.Point coord
           
protected  boolean isNull
           
protected  Player player
           
protected  java.awt.Point pos
           
protected  int width
           
 
Constructor Summary
Piece()
           
 
Method Summary
abstract  void drawChecker(java.awt.Graphics g)
          This method is a forward declaration for the draw methods in King and Pawn.
 void executeMove(int col, int row, Board b)
          Since the move has been verified as valid this method only concerns itself with moving the pieces.
 int getCheckerNumber()
          This method gets the number of the current piece public
 int getCol()
          This method gets protected information from the Piece class.
 java.awt.Color getColor()
          This method gets protected information from the checker class.
 int getRow()
          This method gets protected information from the Piece class.
 int getWidth()
          This method gets protected information from the Piece class.
 int getXpos()
          This method gets protected information from the Piece class.
 int getYpos()
          This method gets protected information from the Piece class.
 void hasBeenJumped(Square containedBy)
          This method removes a jumped piece from the board.
abstract  boolean isKing()
          This method is a forward declaration for a functor that returns whether or not the piece is a King.
abstract  boolean isMoveValid(boolean isBlackSquare, boolean isNotEmpty, int c, int r, Board b)
          This method check to see if a checker move is valid.
 boolean isNull()
          This method checks to see if the current piece is "null".
 void setCheckerNumber(int chNo)
          This method sets the number of the current piece public
 void setCol(int c)
          This method sets col.
 void setColor(java.awt.Color c)
          This method sets color.
 void setRow(int r)
          This method sets row.
 void setWidth(int w)
          This method sets width of the piece.
 void setXpos(int x)
          This method sets x position in pixels.
 void setYpos(int y)
          This method sets y position in pixels.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pos

protected java.awt.Point pos

coord

protected java.awt.Point coord

width

protected int width

color

protected java.awt.Color color

player

protected Player player

checkerNumber

protected int checkerNumber

isNull

protected boolean isNull
Constructor Detail

Piece

public Piece()
Method Detail

getXpos

public int getXpos()
This method gets protected information from the Piece class. public

Returns:
the x position of the piece in pixels

setXpos

public void setXpos(int x)
This method sets x position in pixels. public

Parameters:
x - the x position of the piece in pixels

getYpos

public int getYpos()
This method gets protected information from the Piece class. public

Returns:
the y position of the piece in pixels

setYpos

public void setYpos(int y)
This method sets y position in pixels. public

Parameters:
y - the y position of the piece in pixels

getColor

public java.awt.Color getColor()
This method gets protected information from the checker class. public

Returns:
color of the checker piece

setColor

public void setColor(java.awt.Color c)
This method sets color. public

Parameters:
c - sets the new color for the piece

getCol

public int getCol()
This method gets protected information from the Piece class. public

Returns:
the x coordinate of the Piece

setCol

public void setCol(int c)
This method sets col. public

Parameters:
c - the x coordinate of the Piece

getRow

public int getRow()
This method gets protected information from the Piece class. public

Returns:
y coordinate of the Piece

setRow

public void setRow(int r)
This method sets row. public

Parameters:
r - sets the y coordinate of the piece

getWidth

public int getWidth()
This method gets protected information from the Piece class. public

Returns:
the width of the piece

setWidth

public void setWidth(int w)
This method sets width of the piece. public

Parameters:
w - the width of the piece

isMoveValid

public abstract boolean isMoveValid(boolean isBlackSquare,
                                    boolean isNotEmpty,
                                    int c,
                                    int r,
                                    Board b)
This method check to see if a checker move is valid. public

Parameters:
isBlackSquare - true if it is occupiable square
isNotEmpty - true if the square has a piece
c - destination of x coordinate
r - destination of y coordinate
b - a reference to Board
Returns:
true if the move is valid

hasBeenJumped

public void hasBeenJumped(Square containedBy)
This method removes a jumped piece from the board. public

Parameters:
containedBy - the square that contains this piece

getCheckerNumber

public int getCheckerNumber()
This method gets the number of the current piece public

Returns:
the piece number

setCheckerNumber

public void setCheckerNumber(int chNo)
This method sets the number of the current piece public

Parameters:
chNo - Sets the number of the current piece

isNull

public boolean isNull()
This method checks to see if the current piece is "null". Rather than having truly null pieces, this method allows the program to verify whether or not it is dealing with a valid piece.

Returns:
True if the piece is not currently defined for play.

drawChecker

public abstract void drawChecker(java.awt.Graphics g)
This method is a forward declaration for the draw methods in King and Pawn. public

Parameters:
g - the passed Graphics object

isKing

public abstract boolean isKing()
This method is a forward declaration for a functor that returns whether or not the piece is a King. public

Returns:
True if the piece is a member of the King

executeMove

public void executeMove(int col,
                        int row,
                        Board b)
Since the move has been verified as valid this method only concerns itself with moving the pieces.

Parameters:
col - x coordinate of its destination
row - y coordinate of its destination
b - a reference to the board in order to refer to other pieces