Class PieceMove

java.lang.Object
  extended by PieceMove

public class PieceMove
extends java.lang.Object

PieceMove represents the movement of one piece in the puzzle. It holds references to the Piece object that is on the old position and to the piece object that is in the new position.

Version:
2005-10-30, JDK 1.5.0.5, Eclipse 3.1.0, Windows XP, CS 340, Fall 2005, Instructor: Pat Troy, TA: Nitin Jindal
Author:
Michael Leonhard (mleonhar)

Field Summary
private  char axis
           
private  int delta
           
private  Piece destPiece
           
private  Piece sourcePiece
           
 
Constructor Summary
PieceMove(Piece source, Piece dest, char axis, int delta)
          Constructor: initializes the data members with the provided values
 
Method Summary
 char getAxis()
          Accessor for axis of movement
 int getDelta()
          Accessor for distance and direction travelled
 Piece getDestPiece()
          Accessor for the post-move piece
 Piece getSourcePiece()
          Accessor for the pre-move piece
 java.lang.String prettyString()
          Makes a nice human readable string representation of the move
 java.lang.String toString()
          Makes a compact human readable string representation of the move
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sourcePiece

private Piece sourcePiece

destPiece

private Piece destPiece

axis

private char axis

delta

private int delta
Constructor Detail

PieceMove

public PieceMove(Piece source,
                 Piece dest,
                 char axis,
                 int delta)
Constructor: initializes the data members with the provided values

Parameters:
source - the piece before movement
dest - the piece after movement
axis - the axis of travel (must be H_MOVE or V_MOVE)
delta - the distance and direction travelled on the axis (may not be zero)
Method Detail

toString

public java.lang.String toString()
Makes a compact human readable string representation of the move

Overrides:
toString in class java.lang.Object
Returns:
string version of move

prettyString

public java.lang.String prettyString()
Makes a nice human readable string representation of the move

Returns:
pretty string version of move

getDelta

public int getDelta()
Accessor for distance and direction travelled

Returns:
the distance travelled, sign indicates direction

getAxis

public char getAxis()
Accessor for axis of movement

Returns:
the axis of movement, V_MOVE or H_MOVE

getSourcePiece

public Piece getSourcePiece()
Accessor for the pre-move piece

Returns:
the source piece

getDestPiece

public Piece getDestPiece()
Accessor for the post-move piece

Returns:
the destination piece