ggz.cards.common
Class Card
java.lang.Object
ggz.cards.common.Card
public class Card
- extends java.lang.Object
A card.
Method Summary |
boolean |
equals(java.lang.Object o)
|
Face |
getFace()
|
Suit |
getSuit()
|
int |
hashCode()
Taken from the example on p.39 of Effective Java by Joshua Bloch. |
boolean |
isFaceUp()
Determines whether it's known what suit and face this card is. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
UNKNOWN_CARD
public static final Card UNKNOWN_CARD
Card
public Card(Face face,
Suit suit)
getSuit
public Suit getSuit()
getFace
public Face getFace()
isFaceUp
public boolean isFaceUp()
- Determines whether it's known what suit and face this card is. The server
only notifies us the suit and face if we can see it, hence it will be
"face up".
- Returns:
- true iff face != UNKNOWN_FACE and suit != UNKNOWN_SUIT.
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in class java.lang.Object
hashCode
public int hashCode()
- Taken from the example on p.39 of Effective Java by Joshua Bloch. A
better solution would be not to implement equals() and hashCode() and to
instead make the constructors private and provide a static getCard()
method that returns the appropriate card from a static set of cards since
cards are a finite set. However, we also have to think about what happens
when there are two decks in the game and what that means for equality.
- Overrides:
hashCode
in class java.lang.Object
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object