|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectrules.Piece
public final class Piece
This is the piece object, this object contains a hexadecimal location, piece type and colour. Once you instantiate a piece object, it is considered immutable, that means, the contents cannot be changed. You must reassign your variables to achieve the desired effect, like with a string.
Field Summary | |
---|---|
static byte |
BISHOP
The identifier for bishops. |
static byte |
BLACK
The colour/side identifier for black pieces. |
static byte |
KING
The identifier for the king. |
static byte |
KNIGHT
The identifier for knights. |
static byte |
NULL
The identifier for the null piece. |
static byte |
NULL_COL
The colour/side identifier for null pieces. |
static int |
NUM_SIDES
The number of players in the game. |
static byte |
PAWN
The identifier for pawns. |
static byte |
QUEEN
The identifier for the queen. |
static byte |
ROOK
The identifier for rooks. |
static byte |
WHITE
The colour/side identifier for white pieces. |
Constructor Summary | |
---|---|
Piece(byte x88loc,
byte ptype,
byte colour)
Makes a piece with the given position 0x88 coordinate and type (and state = true). |
Method Summary | |
---|---|
Piece |
destroy()
Returns the "null piece", or a piece that has no defined colour or piece type. |
boolean |
exists()
Returns whether or not the piece is on the board. |
byte |
getColour()
Returns the colour of the piece. |
static Piece |
getNullPiece()
Returns the null piece. |
byte |
getPosition()
Returns the position of the piece. |
byte |
getType()
Returns the type of the piece as defined by the piece constants above. |
boolean |
isEqual(Piece other)
Compares this piece to another piece for equality. |
Piece |
move(byte difference)
Moves a piece a 0x88 difference in decimal, that is, the difference between 0x58 and 0x70 is actually not 12. |
Piece |
move(Move m)
Applies a Move m to this object. |
java.lang.String |
toString()
Returns a string representation of this Piece object. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int NUM_SIDES
public static final byte WHITE
public static final byte BLACK
public static final byte NULL_COL
public static final byte PAWN
public static final byte ROOK
public static final byte KNIGHT
public static final byte BISHOP
public static final byte QUEEN
public static final byte KING
public static final byte NULL
Constructor Detail |
---|
public Piece(byte x88loc, byte ptype, byte colour)
x88loc
- the 0x88 location of the piece.ptype
- the type of the piece (pawn, knight, etc..) according to the constants.colour
- the colour of the piece.Method Detail |
---|
public boolean exists()
public byte getColour()
public byte getPosition()
public byte getType()
public Piece move(byte difference)
Piece p = new Piece (32, 4, 3);
p = p.move (15)
Note: You can actually move your piece out of the board. Just use the
exists() method to test whether or not it is out of the board.
difference
- between the squares in decimal.
public Piece move(Move m)
public Piece destroy()
Piece p = new Piece (32, 4, 3);
p = p.destroy();
public static Piece getNullPiece()
public boolean isEqual(Piece other)
otherPiece
- The piece to be compared to.
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |