inonit.domain.game.card
Class Suit
java.lang.Object
|
+--inonit.domain.game.card.Suit
- All Implemented Interfaces:
- java.io.Serializable
- public class Suit
- extends java.lang.Object
- implements java.io.Serializable
A suit of playing cards; Card
s have a particular Suit
.
Suit
s are conceptually values; two Suit
s with the same name are interchangeable.
Suits
are immutable.
Has four instances declared as public static final
representing the suits in a normal deck
of playing cards; these are not individually documented.
- See Also:
- Serialized Form
Method Summary |
boolean |
equals(java.lang.Object o)
Returns whether the given object is equal to this object. |
java.lang.String |
getName()
Returns the name of this Suit . |
char |
getSymbol()
Returns a character symbol for this Suit , e.g., '♣' for Suit.CLUBS . |
int |
hashCode()
Returns a hash code for this object. |
java.lang.String |
toString()
Returns a string representation of this Suit . |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
CLUBS
public static final Suit CLUBS
DIAMONDS
public static final Suit DIAMONDS
SPADES
public static final Suit SPADES
HEARTS
public static final Suit HEARTS
toString
public java.lang.String toString()
- Returns a string representation of this
Suit
.
- Overrides:
toString
in class java.lang.Object
- Returns:
- a string representing the
Suit
, e.g., "Suit: Clubs" for
Suit.CLUBS
, which may be useful for debugging.
equals
public boolean equals(java.lang.Object o)
- Returns whether the given object is equal to this object.
- Overrides:
equals
in class java.lang.Object
- Parameters:
o
- the object to which to compare this one.- Returns:
true
if the given object is a Suit
which has the same name as this one;
false
otherwise.
hashCode
public int hashCode()
- Returns a hash code for this object.
- Overrides:
hashCode
in class java.lang.Object
- Returns:
- a hash code for this object consistent with the implementation of
equals
.
getName
public java.lang.String getName()
- Returns the name of this
Suit
.
- Returns:
- The name of this
Suit
, e.g., "Clubs" for Suit.CLUBS
.
getSymbol
public char getSymbol()
- Returns a character symbol for this
Suit
, e.g., '♣' for Suit.CLUBS
.
Support for these special characters is spotty; it may be
safer to use the first character of the String
returned from getName
instead.
- Returns:
- a
char
symbol for this Suit
.