model.moves
Class Promotion

java.lang.Object
  extended by model.moves.Move
      extended by model.moves.Promotion
Direct Known Subclasses:
CapturePromotion

public class Promotion
extends Move

Represents the Promotion move. The Move where a pawn reaches the last line of the ChessBoard and can convert to queen, rook, knight or bishop.


Constructor Summary
Promotion(Cell x, Cell y)
          constructor: Creates a new Promotion Move.
 
Method Summary
 boolean move(ChessBoard x)
          transformer(mutative): Applies a Promotion move on the given ChessBoard.
 void prev(ChessBoard x)
          transformer(mutative): Takes the ChessBoard a move back.
 void setPromotedTo(Piece what)
          transformer(mutative):Sets the piece to be promoted to the one passed as argument.
 java.lang.String toString()
          accessor(selector): Creates a String representation of the Promotion move.
 
Methods inherited from class model.moves.Move
equals, getFrom, getTo
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Promotion

public Promotion(Cell x,
                 Cell y)
constructor: Creates a new Promotion Move.
postcondition: Creates a new Promotion Move(this Move happens when a pawn reaches the end of the board).

Parameters:
x - source cell
y - destination cell
Method Detail

move

public boolean move(ChessBoard x)
transformer(mutative): Applies a Promotion move on the given ChessBoard.
postcondition: A promotion move is applied on the ChessBoard.

Overrides:
move in class Move
Parameters:
x - Is the ChessBoard the changes will be applied.
Returns:
true if the move is successfully, false otherwise.

setPromotedTo

public void setPromotedTo(Piece what)
transformer(mutative):Sets the piece to be promoted to the one passed as argument.
postcondition:Sets the newly promoted piece to the one passed as argument

Parameters:
what - The piece to be promoted to.

prev

public void prev(ChessBoard x)
transformer(mutative): Takes the ChessBoard a move back.
postcondition: Does the reverse of the given move, goes from destination Cell back to source Cell.

Overrides:
prev in class Move
Parameters:
x - is the ChessBoard that the changes will be applied.

toString

public java.lang.String toString()
accessor(selector): Creates a String representation of the Promotion move.
postcondition: Creates a String display of Promotion.

Overrides:
toString in class Move
Returns:
A string to show Promotion.