com.webstersmalley.chessweb.model
Class Board

java.lang.Object
  extended by com.webstersmalley.chessweb.model.Board
Direct Known Subclasses:
StandardBoard

public class Board
extends java.lang.Object

Represents the current state of the chessboard.

Author:
Matthew Smalley

Constructor Summary
Board()
           
 
Method Summary
 Piece getAt(Position pos)
          Return the piece at a given position.
 Piece getAt(java.lang.String file, int rank)
          Return the piece at a given location.
 java.lang.String getChecked()
          Returns a message indicating if either team is checked.
 int getHeight()
          Accessor for the height variable.
 MoveHistory getMoveHistory()
           
 Team getNextTurn()
           
 java.util.Collection getSquares()
          Returns the collection of all Squares.
 int getWidth()
          Accessor for the width variable.
 boolean isBlackChecked()
           
 boolean isOnBoard(Position position)
          Checks whether a given position is on the board.
 boolean isWhiteChecked()
           
 void movePiece(Move move)
          Move a piece from one position to another.
 void place(Position pos, Piece piece)
          Place a piece at a position.
 void setBlackChecked(boolean blackChecked)
           
 void setHeight(int height)
          Mutator for the height variable.
 void setNextTurn(Team nextTurn)
           
protected  void setup()
          Sets up the Square objects.
 void setWhiteChecked(boolean whiteChecked)
           
 void setWidth(int width)
          Mutator for the width variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Board

public Board()
Method Detail

setup

protected final void setup()
Sets up the Square objects.


getHeight

public final int getHeight()
Accessor for the height variable.

Returns:
the height

setHeight

public final void setHeight(int height)
Mutator for the height variable.

Parameters:
height - the new height.

getWidth

public final int getWidth()
Accessor for the width variable.

Returns:
the width

setWidth

public final void setWidth(int width)
Mutator for the width variable.

Parameters:
width - the new width.

getAt

public final Piece getAt(Position pos)
Return the piece at a given position.

Parameters:
pos - the Position.
Returns:
the piece.

getAt

public final Piece getAt(java.lang.String file,
                         int rank)
Return the piece at a given location.

Parameters:
file - the file coordinate
rank - the rank coordinate
Returns:
the piece.

movePiece

public final void movePiece(Move move)
                     throws InvalidMoveException
Move a piece from one position to another.

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

place

public final void place(Position pos,
                        Piece piece)
Place a piece at a position. Private method, as this should be accessed via movePiece instead.

Parameters:
pos - the position
piece - the piece

getSquares

public final java.util.Collection getSquares()
Returns the collection of all Squares.

Returns:
the collection of all Squares.

isOnBoard

public final boolean isOnBoard(Position position)
Checks whether a given position is on the board.

Parameters:
position - the position
Returns:
whether it is on the board or not.

getMoveHistory

public final MoveHistory getMoveHistory()
Returns:
Returns the moveHistory.

setNextTurn

public final void setNextTurn(Team nextTurn)
Parameters:
nextTurn - The nextTurn to set.

getNextTurn

public final Team getNextTurn()
Returns:
Returns the nextTurn.

isBlackChecked

public final boolean isBlackChecked()
Returns:
Returns the blackChecked.

setBlackChecked

public final void setBlackChecked(boolean blackChecked)
Parameters:
blackChecked - The blackChecked to set.

isWhiteChecked

public final boolean isWhiteChecked()
Returns:
Returns the whiteChecked.

setWhiteChecked

public final void setWhiteChecked(boolean whiteChecked)
Parameters:
whiteChecked - The whiteChecked to set.

getChecked

public final java.lang.String getChecked()
Returns a message indicating if either team is checked.

Returns:
the checked message.


Copyright © 2005 Webster Smalley. All Rights Reserved.