|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectps0.optional.Card
public class Card extends Object implements Comparable<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 and Description |
---|
Card(CardValue aValue,
CardSuit aSuit)
Creates a new playing card. |
Modifier and Type | Method and Description |
---|---|
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 cardCard
objectMethod Detail |
---|
public CardSuit getSuit()
CardSuit
associated with this cardpublic CardValue getValue()
CardValue
associated with this cardpublic 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 comparedClassCastException
- if the specified object's type is not CardNullPointerException
- if the specified object is nullo
is not an instance of Card, throws a
ClassCastException
o
is null, throws a
NullPointerException
Card
is less than, equal to, or greater than the specified
Card
, respectivelypublic 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 |