rules
Class Position.Piece

java.lang.Object
  extended by rules.Position.Piece
Enclosing class:
Position

public final class Position.Piece
extends java.lang.Object

This is an immutable Piece class that stores the type and location of the piece. Once a Piece object is created, it cannot be changed. This avoids memory reference issues. To move a piece, simply use the movePiece method and reassign the reference.


Field Summary
 byte square
          The square that the piece currently occupies.
 char type
          The type of chess piece that this object represents.
 
Constructor Summary
Position.Piece(byte square, char type)
          Constructor: Constructs a given chess piece based on it's current square and its type.
 
Method Summary
 Position.Piece movePiece(byte dest)
          Moves a piece to it's destination.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

square

public final byte square
The square that the piece currently occupies.


type

public final char type
The type of chess piece that this object represents.

Constructor Detail

Position.Piece

public Position.Piece(byte square,
                      char type)
Constructor: Constructs a given chess piece based on it's current square and its type.

Parameters:
square - The square that the piece occupies in the 0x88 scheme.
type - Capital for white pieces, lower-case for black pieces. p = pawn, n = knight, b = bishop, r = rook, q = queen, and k = king.
Method Detail

movePiece

public Position.Piece movePiece(byte dest)
Moves a piece to it's destination.

Parameters:
dest - The square that the piece will occupy.
Returns:
The new reference to the piece.