|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Piece represents an immutable playing piece on a board.
Each Piece object corresponds to a different physical object. So Piece.equals() (and Piece.hashCode()) implement referential equality: p1.equals(p2) if and only if p1 == p2.
Piece.similar() implements observational equality. If Piece objects p1 and p2 are indistinguishable for the rules of some particular game -- i.e., p1 and p2 could be swapped on the board without changing the board state -- then p1.similar(p2) is true. For example, two black pawns would be similar but not equal.
Method Summary | |
boolean |
equals(Object obj)
Test for referential equality with another object. |
int |
hashCode()
Get hash code for this object. |
boolean |
similar(Object obj)
Test for observational equality with another object. |
String |
toString()
Get string representation of this piece. |
Method Detail |
public boolean equals(Object obj)
obj
- Object to test
public int hashCode()
public boolean similar(Object obj)
obj
- Object to test
public String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |