|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectps0.optional.Card
public class Card
Card is a class representing single playing card consisting of a value and a suit (e.g. [Ace,Spades],[10,Clubs]). Cards are immutable; once a Card has been created with a given value and suit, that value and suit cannot be changed.
Constructor Summary | |
---|---|
Card(CardValue aValue,
CardSuit aSuit)
Creates a new playing card. |
Method Summary | |
---|---|
int |
compareTo(Card c)
Compares this card with the specified card for order. |
boolean |
equals(Object otherCardObject)
Returns true if this card is equal to the other card. |
CardSuit |
getSuit()
|
CardValue |
getValue()
|
int |
hashCode()
Returns a hashcode for this object. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Card(CardValue aValue, CardSuit aSuit)
aValue
- the value of this cardaSuit
- the suit of this cardMethod Detail |
---|
public CardSuit getSuit()
public CardValue getValue()
public int compareTo(Card c)
Cards are ranked primarily by number, secondarily by suit. That means that this card is ranked lower than another card if one of these conditions is met:
compareTo
in interface Comparable<Card>
c
- the Card to be compared
ClassCastException
- if the specified object's type is not Card
NullPointerException
- if the specified object is nullpublic boolean equals(Object otherCardObject)
equals
in class Object
otherCardObject
- the other cardpublic int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |