game
Class PieceLocation

java.lang.Object
  extended bygame.PieceLocation

public class PieceLocation
extends Object

PieceLocation represents a Piece in a particular square on a particular board. PieceLocations are immutable.

Note that a PieceLocation object might be historical or hypothetical; it doesn't have to describe the piece's true current location. So board.getPieceAt(row,col) does not necessarily return piece.


Constructor Summary
PieceLocation(Board board, Piece piece, int row, int col)
          Make a PieceLocation.
 
Method Summary
 boolean equals(Object obj)
          Test whether another object is equal to this, by observational equality.
 Board getBoard()
          Get the board referenced by this piece location.
 int getColumn()
          Get the column referenced by this piece location.
 Piece getPiece()
          Get the piece referenced by this piece location.
 int getRow()
          Get the row referenced by this piece location.
 int hashCode()
          Get a hash code for this object.
 String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PieceLocation

public PieceLocation(Board board,
                     Piece piece,
                     int row,
                     int col)
Make a PieceLocation.

Parameters:
board - board containing piece (not null)
piece - piece in board (not null)
row - row number in the range [0,board.size-1]
col - column number in the range [0,board.size-1]
Method Detail

getBoard

public Board getBoard()
Get the board referenced by this piece location.

Returns:
board referenced by this piece location.

getPiece

public Piece getPiece()
Get the piece referenced by this piece location.

Returns:
piece referenced by this piece location.

getRow

public int getRow()
Get the row referenced by this piece location.

Returns:
row referenced by this piece location, in the range [0,board.size-1]

getColumn

public int getColumn()
Get the column referenced by this piece location.

Returns:
column referenced by this piece location, in the range [0,board.size-1]

equals

public boolean equals(Object obj)
Test whether another object is equal to this, by observational equality.

Returns:
true if and only if obj is a PieceLocation that refers to the same board, piece, and square

hashCode

public int hashCode()
Get a hash code for this object.

Returns:
hash code such that two equal PieceLocations are guaranteed to return the same hash code

toString

public String toString()