|
Class Chesspiece
java.lang.Object
|
+----Chesspiece
-
public class Chesspiece
-
extends Object
-
Chesspiece()
-
Default constructor
-
Chesspiece(Chessboard)
-
Constructor -- initializes the current game
-
CheckTaking(int,
int, boolean, Chesspiece[][])
-
Determines if a piece is taking another piece
-
GetColor()
-
Gets the color of the piece
-
GetName()
-
Gets the name of the piece
-
HaveCastled()
-
Check and see if king has moved Overridden in King.java
-
HaveMoved()
-
Check and see if rook has moved Overridden in Castle.java
-
IsCastle(int,
int, Chesspiece[][])
-
Determines if the move is a valid attempt at castling Overridden in King.java
-
Moved()
-
Tells the king he has castled or given up castling rights Overridden in
King.java
-
MoveScore(Chesspiece[][])
-
Scores the possible moves
-
SetIdentity(boolean,
char, int, int)
-
Sets the name and color of the piece
-
SetNotFirst()
-
Sets the FirstMove flag for pawn to false after it makes its first move
Overridden in Pawn.jave
-
TellMeWhereIAm(int,
int)
-
Tells the pieces its new location after moving
-
ValidMove(int,
int, boolean, Chesspiece[][])
-
Validates a given position Must be overridden in each piece
Chesspiece
public Chesspiece()
-
Default constructor
Chesspiece
public Chesspiece(Chessboard Board)
-
Constructor -- initializes the current game
-
Parameters:
-
Board - a chessboard
HaveCastled
public boolean HaveCastled()
-
Check and see if king has moved Overridden in King.java
-
Returns:
-
true if king has moved ( and thus, cannot castle )
SetNotFirst
public void SetNotFirst()
-
Sets the FirstMove flag for pawn to false after it makes its first move
Overridden in Pawn.jave
HaveMoved
public boolean HaveMoved()
-
Check and see if rook has moved Overridden in Castle.java
-
Returns:
-
true if rook has moved yet ( used for castling )
IsCastle
public boolean IsCastle(int X2,
int Y2,
Chesspiece Chessboard[][])
-
Determines if the move is a valid attempt at castling Overridden in King.java
-
Parameters:
-
X - x-coordinate of target
-
Y - y-coordinate of target
-
Board - the current chessboard
-
Returns:
-
true if the move is a valid castle
Moved
public void Moved()
-
Tells the king he has castled or given up castling rights Overridden in
King.java
SetIdentity
protected void SetIdentity(boolean BeBlack,
char ChPieceName,
int Row,
int Col)
-
Sets the name and color of the piece
-
Parameters:
-
BeBlack - true if the piece is Black
-
ChPieceName - the name of the piece
-
Row - the row ( rank ) coordinate
-
Col - the column ( file ) coordinate
TellMeWhereIAm
public void TellMeWhereIAm(int Col,
int Row)
-
Tells the pieces its new location after moving
-
Parameters:
-
Row - is row coordinate
-
Col - is column coordinate
-
Returns:
-
Piece has a name and color
GetName
public char GetName()
-
Gets the name of the piece
-
Returns:
-
character denoting the name of the piece
GetColor
public boolean GetColor()
-
Gets the color of the piece
-
Returns:
-
true if the piece is black
ValidMove
public boolean ValidMove(int X2,
int Y2,
boolean BeBlack,
Chesspiece Board[][])
-
Validates a given position Must be overridden in each piece
-
Parameters:
-
X - x-coordinate of move
-
Y - y-coordinate of move
-
Taking - true if we are capturing opponent's piece
-
Board - the chessboard currently in play
-
Returns:
-
true if move is valid
MoveScore
public int MoveScore(Chesspiece Board[][])
-
Scores the possible moves
-
Parameters:
-
Board - the current chessboard
-
Returns:
-
a score denoting the number of spaces the piece controls.
CheckTaking
public boolean CheckTaking(int X,
int Y,
boolean BeBlack,
Chesspiece Board[][])
-
Determines if a piece is taking another piece
-
Parameters:
-
X - x-coordinate of destination
-
Y - y-coordinate of destination
-
BeBlack - true if the player is black
-
Board - the current chessboard
-
Returns:
-
true if there is an opponent's piece at the target
|