de.java_chess.javaChess.piece
Class PieceImpl

java.lang.Object
  |
  +--de.java_chess.javaChess.piece.PieceImpl

public class PieceImpl
extends java.lang.Object
implements Piece

This class implements the functionality for a piece.


Fields inherited from interface de.java_chess.javaChess.piece.Piece
BISHOP, BLACK, KING, KNIGHT, PAWN, QUEEN, ROOK, WHITE
 
Constructor Summary
PieceImpl(byte typeColor)
          Create a new piece instance.
PieceImpl(byte type, byte color)
          Create a new Piece instance from type and color.
 
Method Summary
 byte getColor()
          Get the color of this piece.
 byte getType()
          Get the type of this piece.
 byte getTypeAndColor()
          Get type and color as 1 byte.
 boolean isWhite()
          Check, if this piece is white.
 void setColor(byte color)
          Set the color of this piece.
 void setType(byte type)
          Set the type of this piece.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PieceImpl

public PieceImpl(byte typeColor)
Create a new piece instance.
Parameters:
typeColor - The color and type of piece, with color in bit 0 and the type color in bit 1-3.

PieceImpl

public PieceImpl(byte type,
                 byte color)
Create a new Piece instance from type and color.
Parameters:
type - The type of the piece.
color - The color of the piece.
Method Detail

getType

public final byte getType()
Get the type of this piece.
Specified by:
getType in interface Piece
Returns:
The type of this piece.

setType

public final void setType(byte type)
Set the type of this piece.
Specified by:
setType in interface Piece
Parameters:
type - The type of this piece as defined as constants in the Piece interface.

getColor

public final byte getColor()
Get the color of this piece.
Specified by:
getColor in interface Piece
Returns:
The color of this piece.

setColor

public final void setColor(byte color)
Set the color of this piece.
Specified by:
setColor in interface Piece
Parameters:
The - new color of this piece.

isWhite

public final boolean isWhite()
Check, if this piece is white.
Specified by:
isWhite in interface Piece
Returns:
true, if this piece is white, false if black.

getTypeAndColor

public final byte getTypeAndColor()
Get type and color as 1 byte.
Specified by:
getTypeAndColor in interface Piece
Returns:
Type and color and 1 byte.