|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--inonit.domain.game.card.Card
A playing card, with a Rank
and a Suit
.
Card
s are conceptually values; thus, a Card
with a given Rank
and Suit
is interchangeable with another Card
with the same Rank
and Suit
. Card
s are immutable.
Constant Card
instances representing
the cards in a normal deck are declared as
public static final
in this
class and are not individually documented.
Collections of Card
s can be manipulated via the CardArray
class.
Inner Class Summary | |
static class |
Card.Order
A logical ordering of a set of Card s. |
Method Summary | |
boolean |
equals(java.lang.Object o)
Returns whether this object equals the given Object . |
static Card |
get(Rank rank,
Suit suit)
Returns a Card object of the given Rank and Suit . |
java.lang.String |
getAbbreviation()
Returns an abbreviated string representation of this card. |
Rank |
getRank()
Returns the Rank of this Card . |
Suit |
getSuit()
Returns the Suit of this Card . |
int |
hashCode()
Returns a hash code for this object. |
boolean |
isSameRankAs(Card card)
Returns whether the given Card and this Card have the same Rank . |
boolean |
isSameSuitAs(Card card)
Returns whether the given Card and this Card have the same Suit . |
java.lang.String |
toString()
Returns a string representation of this object. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final Card TWO_CLUBS
public static final Card THREE_CLUBS
public static final Card FOUR_CLUBS
public static final Card FIVE_CLUBS
public static final Card SIX_CLUBS
public static final Card SEVEN_CLUBS
public static final Card EIGHT_CLUBS
public static final Card NINE_CLUBS
public static final Card TEN_CLUBS
public static final Card JACK_CLUBS
public static final Card QUEEN_CLUBS
public static final Card KING_CLUBS
public static final Card ACE_CLUBS
public static final Card TWO_DIAMONDS
public static final Card THREE_DIAMONDS
public static final Card FOUR_DIAMONDS
public static final Card FIVE_DIAMONDS
public static final Card SIX_DIAMONDS
public static final Card SEVEN_DIAMONDS
public static final Card EIGHT_DIAMONDS
public static final Card NINE_DIAMONDS
public static final Card TEN_DIAMONDS
public static final Card JACK_DIAMONDS
public static final Card QUEEN_DIAMONDS
public static final Card KING_DIAMONDS
public static final Card ACE_DIAMONDS
public static final Card TWO_SPADES
public static final Card THREE_SPADES
public static final Card FOUR_SPADES
public static final Card FIVE_SPADES
public static final Card SIX_SPADES
public static final Card SEVEN_SPADES
public static final Card EIGHT_SPADES
public static final Card NINE_SPADES
public static final Card TEN_SPADES
public static final Card JACK_SPADES
public static final Card QUEEN_SPADES
public static final Card KING_SPADES
public static final Card ACE_SPADES
public static final Card TWO_HEARTS
public static final Card THREE_HEARTS
public static final Card FOUR_HEARTS
public static final Card FIVE_HEARTS
public static final Card SIX_HEARTS
public static final Card SEVEN_HEARTS
public static final Card EIGHT_HEARTS
public static final Card NINE_HEARTS
public static final Card TEN_HEARTS
public static final Card JACK_HEARTS
public static final Card QUEEN_HEARTS
public static final Card KING_HEARTS
public static final Card ACE_HEARTS
Method Detail |
public static Card get(Rank rank, Suit suit)
Card
object of the given Rank
and Suit
.rank
- A Rank
. Must not be null
.suit
- A Suit
. Must not be null
.Card
object which has the given Rank
and Suit
.public java.lang.String toString()
toString
in class java.lang.Object
Card: 2 Clubs
for Card.TWO_CLUBS
,
which may be useful for debugging.public boolean equals(java.lang.Object o)
Object
.
A Card
is equal to another
Card
if it
is of the same Rank
and Suit
.equals
in class java.lang.Object
o
- the object to which to compare this one.true
if o
is a Card
and has the same Rank
and
Suit
as this Card
; false
otherwise.public int hashCode()
hashCode
in class java.lang.Object
Card
consistent with the implementation of equals
.public Rank getRank()
Rank
of this Card
.Rank
of this Card
, e.g., Rank.TWO
for TWO_CLUBS
.public boolean isSameRankAs(Card card)
Card
and this Card
have the same Rank
.card
- Another Card
. Must not be null
.true
if the given Card
has the same Rank
as this
Card
; false
otherwise.public Suit getSuit()
Suit
of this Card
.Suit
of this Card
, e.g., Suit.CLUBS
for
TWO_CLUBS
.public boolean isSameSuitAs(Card card)
Card
and this Card
have the same Suit
.card
- Another Card
. Must not be null
.true
if the given Card
is of the same Suit
as this Card
; false
otherwise.public java.lang.String getAbbreviation()
2C
for Card.TWO_CLUBS
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |