chess
Class ChessPiece

java.lang.Object
  extended by chess.ChessPiece

public class ChessPiece
extends java.lang.Object


Constructor Summary
ChessPiece()
          Creates a new instance of ChessPiece.
ChessPiece(Color col, Piece pc)
          Creates a new instance of ChessPiece.
 
Method Summary
 boolean equals(java.lang.Object obj)
          report whether two chess pieces have equivalent contents
 Color getColor()
          report piece's Color using enum type
 Piece getPiece()
          report piece's type using enum type
 int getValue()
          report value of piece - based solely on its type
 int getValue(Color perspective)
          report value of piece - based solely on its type - but from the perspective of a particular color.
 boolean isEmpty()
          reports whether piece is an empty space.
 void setColor(Color col)
          change pieces color.
 void setPiece(Piece pc)
          change pieces type.
 boolean switchColor()
           
 java.lang.String toShortString()
          report what a piece is in a short string - for presenting a whole board
 java.lang.String toString()
          report what the piece is in a nice string
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ChessPiece

public ChessPiece()
Creates a new instance of ChessPiece. just take defaults - an empty spot on the board


ChessPiece

public ChessPiece(Color col,
                  Piece pc)
Creates a new instance of ChessPiece. use passed color and piece

Method Detail

getColor

public Color getColor()
report piece's Color using enum type


getPiece

public Piece getPiece()
report piece's type using enum type


getValue

public int getValue()
report value of piece - based solely on its type


getValue

public int getValue(Color perspective)
report value of piece - based solely on its type - but from the perspective of a particular color. From the perspective of white - if the piece is black then the value is negative


isEmpty

public boolean isEmpty()
reports whether piece is an empty space. Policy decision - both color and piece must be empty in order to qualify. Other situations should be handled with a isError method


setColor

public void setColor(Color col)
change pieces color. Probably should not be widely used. Piece Color should not change


switchColor

public boolean switchColor()

setPiece

public void setPiece(Piece pc)
change pieces type. Probably should not be widely used. Possible use - pawn reaches end row


equals

public boolean equals(java.lang.Object obj)
report whether two chess pieces have equivalent contents

Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
report what the piece is in a nice string

Overrides:
toString in class java.lang.Object

toShortString

public java.lang.String toShortString()
report what a piece is in a short string - for presenting a whole board