model.pieces
Class King

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

public class King
extends Piece

Represents the King piece


Constructor Summary
King(java.lang.String x, boolean z, javax.swing.Icon r)
          constructor: Constructs a new King 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 King 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 King has moved, thus making it impossible in the future to take place in a castling move.
 boolean isMoved()
          accessor(selector): Tells us whether the King has moved or not.
 java.util.List<Move> moves(Cell p, ChessBoard b)
          Creates and returns a List of all the possible Moves the King can execute.
 java.lang.String toString()
          accessor(selector): Returns a String representation of the King.
 
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

King

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

hasMoved

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

See Also:
Castling

hasMoved

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

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

isMoved

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

Returns:
true if King 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 King can execute.
postcondition: Returns all the possible moves of the King at the given Cell at the given ChessBoard. If the Cell doesn't contain a King or no Piece at all, the empty list is returned.

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

toString

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

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