model.moves
Class Move

java.lang.Object
  extended by model.moves.Move
Direct Known Subclasses:
Capture, Castling, Promotion

public class Move
extends java.lang.Object

Represents a move on the chessboard.


Constructor Summary
Move(Cell a, Cell b)
          constructor: Creates a Move based on the two given cells.
 
Method Summary
 boolean equals(java.lang.Object other)
          accessor(observer): Returns a boolean value on whether the object passed as parameter is equal with the object it is called from.
 Cell getFrom()
          accessor(selector): Returns the source cell of the given Move.
 Cell getTo()
          accessor(selector): Returns the destination cell of the given Move.
 boolean move(ChessBoard x)
          Given a ChessBoard and a Move(this), applies the given Move on the chess board.
 void prev(ChessBoard x)
          Given a ChessBoard performs a reverse Move.
 java.lang.String toString()
          accessor(selector): Returns the String representation of the given move.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Move

public Move(Cell a,
            Cell b)
     throws IllegalCellException
constructor: Creates a Move based on the two given cells.
A Move is characterized by it's source and destination coordinates, that's why the Move constructor takes two Cell(s) as parameters.
precondition: Parameters cannot be equal.
postcondition: Creates a new Move depending on the source and destination cells.

Parameters:
a - source cell
b - destination cell
Throws:
IllegalCellException - if Cell(s) don't correspond to valid Cell(s) or are equal.
See Also:
Cell
Method Detail

getFrom

public Cell getFrom()
accessor(selector): Returns the source cell of the given Move.
postcondition: Retrieves the source cell.

Returns:
the source cell of the Move

getTo

public Cell getTo()
accessor(selector): Returns the destination cell of the given Move.
postcondition: Returns the destination cell of a Move.

Returns:
the destination cell of the Move

move

public boolean move(ChessBoard x)
Given a ChessBoard and a Move(this), applies the given Move on the chess board.
postcondition: Applies the certain Move on a chess board.

Parameters:
x - the ChessBoard that the Move is applied on.
Returns:
true if move was successfully performed, false otherwise

prev

public void prev(ChessBoard x)
Given a ChessBoard performs a reverse Move. Goes from destination to source.
postcondition: Goes one Move back on a chess board.

Parameters:
x - ChessBoard that previous Move is applied on.

toString

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

Overrides:
toString in class java.lang.Object
Returns:
String representation of a Move.

equals

public boolean equals(java.lang.Object other)
accessor(observer): Returns a boolean value on whether the object passed as parameter is equal with the object it is called from.
postcondition: Overrides Object's equals, returns true if objects are equal false otherwise.

Overrides:
equals in class java.lang.Object
Parameters:
other - Object to be compared with