model.pieces
Class Rook

java.lang.Object
  extended by model.pieces.Piece
      extended by model.pieces.Rook

public class Rook
extends Piece

Represents the Rook piece


Constructor Summary
Rook(java.lang.String x, boolean z, javax.swing.Icon r)
          constructor: Constructs a new Rook 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
 void hasMoved()
          transformer(mutative): Notifies that the Rook has moved, thus making it impossible in the future to execute a castling move.
 void hasMoved(boolean what)
          transformer(mutative): Changes the info if the Rook has moved, thus making it impossible in the future to take place in a castling move.
 boolean isMoved()
          accessor(selector): Tells us whether the Rook has moved or not.
 java.util.List<Move> moves(Cell p, ChessBoard b)
          Creates and returns a List of all the possible Moves the Rook can execute.
 java.lang.String toString()
          accessor(selector): Returns a String representation of the Rook.
 
Methods inherited from class model.pieces.Piece
getColor, getIcon, getName, setIcon, setName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Rook

public Rook(java.lang.String x,
            boolean z,
            javax.swing.Icon r)
constructor: Constructs a new Rook 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 Rook 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 Rook.
x - Defines the name of the Rook.
z - Defines the color of the Rook. White for true, black for false.
Method Detail

hasMoved

public void hasMoved()
transformer(mutative): Notifies that the Rook has moved, thus making it impossible in the future to execute a castling move.
postcondition: Certifies that the Rook has performed a move.

See Also:
Castling

hasMoved

public void hasMoved(boolean what)
transformer(mutative): Changes the info if the Rook has moved, thus making it impossible in the future to take place in a castling move.
postcondition: Changes the info of wether the Rook has moved or not.

Parameters:
what - boolean showing wether given rook has moved or not.
See Also:
Castling

isMoved

public boolean isMoved()
accessor(selector): Tells us whether the Rook has moved or not. Returns true if he has, false otherwise.
postcondition: Checks if a Rook has moved, returning true if so, false otherwise.

Returns:
true if Rook has moved, false otherwise.

moves

public java.util.List<Move> moves(Cell p,
                                  ChessBoard b)
Creates and returns a List of all the possible Moves the Rook can execute.
postcondition: Returns all the possible moves of the Rook at the given Cell at the given ChessBoard. If the Cell doesn't contain a Rook or no Piece at all, the empty list is returned.

Specified by:
moves in class Piece
Parameters:
p - Is the Cell of the Rook which the moves we want to find.
b - The ChessBoard on which the Rook's moves are found.
Returns:
List of all of Rook's moves.

toString

public java.lang.String toString()
accessor(selector): Returns a String representation of the Rook.
postcondition: Returns a String display of the Rook.

Overrides:
toString in class Piece
Returns:
a String symbolizing the Rook.