|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--ChessPiece
This is the class used for building all chess pieces. This has integer constants in it for piece types and values. It also has methods for pawn promotion, tracking wether a piece has moved or not, and a few accessor methods to retrieve from the object, such as color, type, etc. Last of all is the copy() method that is used to copy the piece itself, making a new object.
| Field Summary | |
static int |
TYPE_BISHOP
Integer constant representing a bishop. |
static int |
TYPE_KING
Integer constant representing a king. |
static int |
TYPE_KNIGHT
Integer constant representing a knight. |
static int |
TYPE_PAWN
Integer constant representing a pawn. |
static int |
TYPE_QUEEN
Integer constant representing a queen. |
static int |
TYPE_ROOK
Integer constant representing a rook. |
static int |
VALUE_BISHOP
Integer constant holding the point value of a bishop. |
static int |
VALUE_KING
Integer constant holding the point value of a king. |
static int |
VALUE_KNIGHT
Integer constant holding the point value of a knight. |
static int |
VALUE_PAWN
Integer constant holding the point value of a pawn. |
static int |
VALUE_QUEEN
Integer constant holding the point value of a queen. |
static int |
VALUE_ROOK
Integer constant holding the point value of a rook. |
| Constructor Summary | |
ChessPiece(int type,
boolean isWhite)
Builds a new chess piece based on the given type and color. |
|
| Method Summary | |
ChessPiece |
copy()
Returns a field for field copy of this object. |
void |
firstMove()
Needs to be called the first time the piece has moved. |
boolean |
hasMoved()
Needed for king (castling), rooks (castling), and pawns (they can move two spaces initially). |
boolean |
isWhite()
Returns true if the piece is white. |
void |
promotePawn(int type)
This is called when a pawn reaches the other side of the board, allowing it to change into one of the other types of pieces. |
protected void |
setupPiece(int type,
boolean isWhite)
Sets up the piece according to the given data. |
int |
type()
Returns an integer representing the type of piece: pawn, knight, bishop, rook, queen, or king. |
int |
value()
Returns the material value of the piece. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int TYPE_PAWN
public static final int TYPE_KNIGHT
public static final int TYPE_BISHOP
public static final int TYPE_ROOK
public static final int TYPE_QUEEN
public static final int TYPE_KING
public static final int VALUE_PAWN
public static final int VALUE_KNIGHT
public static final int VALUE_BISHOP
public static final int VALUE_ROOK
public static final int VALUE_QUEEN
public static final int VALUE_KING
| Constructor Detail |
public ChessPiece(int type,
boolean isWhite)
| Method Detail |
protected void setupPiece(int type,
boolean isWhite)
public void promotePawn(int type)
public int type()
public boolean isWhite()
public int value()
public boolean hasMoved()
public void firstMove()
public ChessPiece copy()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||