|
|||||||||
| 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 cardCard object| Method 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 compared
ClassCastException - if the specified object's type is not Card
NullPointerException - if the specified object is nullo is not an instance of Card, throws a
ClassCastExceptiono is null, throws a
NullPointerExceptionCard is less than, equal to, or greater than the specified
Card, respectivelypublic boolean equals(Object otherCardObject)
equals in class ObjectotherCardObject - the other cardpublic int hashCode()
hashCode in class Objectpublic String toString()
toString in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||