com.webstersmalley.chessweb.model
Class Piece

java.lang.Object
  extended by com.webstersmalley.chessweb.model.Piece
Direct Known Subclasses:
Bishop, King, Knight, Pawn, Queen, Rook

public abstract class Piece
extends java.lang.Object

Represents an individual chess piece.

Author:
Matthew Smalley

Field Summary
static Piece[] ALL_PIECES
          All the Pieces - used for iterating.
static Piece BLACK_BISHOP
          Black Bishop Piece.
static Piece BLACK_KING
          Black King Piece.
static Piece BLACK_KNIGHT
          Black Knight Piece.
static Piece BLACK_PAWN
          Black Pawn Piece.
static Piece BLACK_QUEEN
          Black Queen Piece.
static Piece BLACK_ROOK
          Black Rook Piece.
static Piece WHITE_BISHOP
          White Bishop Piece.
static Piece WHITE_KING
          White King Piece.
static Piece WHITE_KNIGHT
          White Knight Piece.
static Piece WHITE_PAWN
          White Pawn Piece.
static Piece WHITE_QUEEN
          White Queen Piece.
static Piece WHITE_ROOK
          White Rook Piece.
 
Constructor Summary
Piece(Team team)
          Constructs a new Piece.
 
Method Summary
 java.lang.String getIcon()
          Returns the htmlName.
 java.lang.String getName()
          Get the name of this piece.
 java.lang.String getStartingPositions()
          Returns the starting positions.
 Team getTeam()
           
 boolean isJumper()
           
 boolean moveIsATake(Position destination, Board board)
          Whether the proposed move is a take.
 void setJumper(boolean jumper)
           
 void setStartingPositions(java.lang.String startingPositions)
          Sets the startign positions.
 void setTeam(Team team)
           
abstract  void validateDirection(Move move, Board board)
          Validate a direction.
 void validateMove(Move move, Board board)
          Validate a move.
 void validateTake(Move move, Board board)
          Validate a take.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WHITE_BISHOP

public static final Piece WHITE_BISHOP
White Bishop Piece. *


BLACK_BISHOP

public static final Piece BLACK_BISHOP
Black Bishop Piece. *


WHITE_KING

public static final Piece WHITE_KING
White King Piece. *


BLACK_KING

public static final Piece BLACK_KING
Black King Piece. *


WHITE_KNIGHT

public static final Piece WHITE_KNIGHT
White Knight Piece. *


BLACK_KNIGHT

public static final Piece BLACK_KNIGHT
Black Knight Piece. *


WHITE_PAWN

public static final Piece WHITE_PAWN
White Pawn Piece. *


BLACK_PAWN

public static final Piece BLACK_PAWN
Black Pawn Piece. *


WHITE_QUEEN

public static final Piece WHITE_QUEEN
White Queen Piece. *


BLACK_QUEEN

public static final Piece BLACK_QUEEN
Black Queen Piece. *


WHITE_ROOK

public static final Piece WHITE_ROOK
White Rook Piece. *


BLACK_ROOK

public static final Piece BLACK_ROOK
Black Rook Piece. *


ALL_PIECES

public static final Piece[] ALL_PIECES
All the Pieces - used for iterating. *

Constructor Detail

Piece

public Piece(Team team)
Constructs a new Piece.

Parameters:
team - the team.
Method Detail

getIcon

public final java.lang.String getIcon()
Returns the htmlName.

Returns:
the name

getStartingPositions

public final java.lang.String getStartingPositions()
Returns the starting positions.

Returns:
the starting positions.

setStartingPositions

public final void setStartingPositions(java.lang.String startingPositions)
Sets the startign positions.

Parameters:
startingPositions - the starting positions.

getTeam

public final Team getTeam()
Returns:
Returns the team.

setTeam

public final void setTeam(Team team)
Parameters:
team - The team to set.

getName

public final java.lang.String getName()
Get the name of this piece.

Returns:
the name of the piece

validateMove

public final void validateMove(Move move,
                               Board board)
                        throws InvalidMoveException
Validate a move.

Parameters:
move - the move
board - the board
Throws:
InvalidMoveException - if the move is invalid.

validateDirection

public abstract void validateDirection(Move move,
                                       Board board)
                                throws InvalidMoveException
Validate a direction.

Parameters:
board - the board
move - the move
Throws:
InvalidMoveException - if the move is invalid.

validateTake

public final void validateTake(Move move,
                               Board board)
                        throws InvalidMoveException
Validate a take.

Parameters:
move - the move
board - the board
Throws:
InvalidMoveException - if the move is invalid.

moveIsATake

public final boolean moveIsATake(Position destination,
                                 Board board)
Whether the proposed move is a take. Note this doesn't validate the move or the take.

Parameters:
destination - the destination position.
board - the board
Returns:
whether the move is a take.

isJumper

public final boolean isJumper()
Returns:
Returns the canJump.

setJumper

public final void setJumper(boolean jumper)
Parameters:
jumper - The jumper to set.


Copyright © 2005 Webster Smalley. All Rights Reserved.