model.pieces
Class Knight
java.lang.Object
model.pieces.Piece
model.pieces.Knight
public class Knight
- extends Piece
Represents the Knight piece
|
Constructor Summary |
Knight(java.lang.String x,
boolean z,
javax.swing.Icon r)
constructor: Constructs a new Knight piece, with color
based on the parameter z(white for true, black for false) and name
based on the parameter x and the Icon(parameter r). |
|
Method Summary |
java.util.List<Move> |
moves(Cell p,
ChessBoard b)
Creates and returns a List of all the possible Moves the Knight
can execute. |
java.lang.String |
toString()
accessor(selector): Returns a String representation of the Knight. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Knight
public Knight(java.lang.String x,
boolean z,
javax.swing.Icon r)
- constructor: Constructs a new Knight piece, with color
based on the parameter z(white for true, black for false) and name
based on the parameter x and the Icon(parameter r).
postcondition: Creates a new Knight piece based on the input parameters,
the x parameter for its name, and the z parameter for its color and r parameter
for it's icon.
- Parameters:
r - Defines the icon of the Knight.x - Defines the name of the Knight.z - Defines the color of the Knight. White for true, black for false.
moves
public java.util.List<Move> moves(Cell p,
ChessBoard b)
- Creates and returns a List of all the possible Moves the Knight
can execute.
postcondition: Returns all the possible moves of the Queen at the given
Cell at the given ChessBoard. If the Cell doesn't contain a Knight or no Piece
at all, the empty list is returned.
- Specified by:
moves in class Piece
- Parameters:
p - Is the Cell of the Knight which the moves we want to find.b - The ChessBoard on which the Knight's moves are found.
- Returns:
- List of all of Knight's moves.
toString
public java.lang.String toString()
- accessor(selector): Returns a String representation of the Knight.
postcondition: Returns a String display of the Knight.
- Overrides:
toString in class Piece
- Returns:
- a String symbolizing the Knight.