wyvern.lib.classes.games.card
Class Card

java.lang.Object
  extended bywyvern.lib.classes.games.card.Card
All Implemented Interfaces:
CardConstants

public final class Card
extends java.lang.Object
implements CardConstants

Typesafe enum representing the playing cards in a standard 52-card deck.

Version:
1.0, Oct 02, 2003
Author:
Steve Yegge

Field Summary
static Card ACE_OF_CLUBS
           
static Card ACE_OF_DIAMONDS
           
static Card ACE_OF_HEARTS
           
static Card ACE_OF_SPADES
           
static Card EIGHT_OF_CLUBS
           
static Card EIGHT_OF_DIAMONDS
           
static Card EIGHT_OF_HEARTS
           
static Card EIGHT_OF_SPADES
           
static Card FIVE_OF_CLUBS
           
static Card FIVE_OF_DIAMONDS
           
static Card FIVE_OF_HEARTS
           
static Card FIVE_OF_SPADES
           
static Card FOUR_OF_CLUBS
           
static Card FOUR_OF_DIAMONDS
           
static Card FOUR_OF_HEARTS
           
static Card FOUR_OF_SPADES
           
static Card JACK_OF_CLUBS
           
static Card JACK_OF_DIAMONDS
           
static Card JACK_OF_HEARTS
           
static Card JACK_OF_SPADES
           
static Card KING_OF_CLUBS
           
static Card KING_OF_DIAMONDS
           
static Card KING_OF_HEARTS
           
static Card KING_OF_SPADES
           
static Card NINE_OF_CLUBS
           
static Card NINE_OF_DIAMONDS
           
static Card NINE_OF_HEARTS
           
static Card NINE_OF_SPADES
           
static int NUM_CARDS
           
static Card QUEEN_OF_CLUBS
           
static Card QUEEN_OF_DIAMONDS
           
static Card QUEEN_OF_HEARTS
           
static Card QUEEN_OF_SPADES
           
static Card SEVEN_OF_CLUBS
           
static Card SEVEN_OF_DIAMONDS
           
static Card SEVEN_OF_HEARTS
           
static Card SEVEN_OF_SPADES
           
static Card SIX_OF_CLUBS
           
static Card SIX_OF_DIAMONDS
           
static Card SIX_OF_HEARTS
           
static Card SIX_OF_SPADES
           
static Card TEN_OF_CLUBS
           
static Card TEN_OF_DIAMONDS
           
static Card TEN_OF_HEARTS
           
static Card TEN_OF_SPADES
           
static Card THREE_OF_CLUBS
           
static Card THREE_OF_DIAMONDS
           
static Card THREE_OF_HEARTS
           
static Card THREE_OF_SPADES
           
static Card TWO_OF_CLUBS
           
static Card TWO_OF_DIAMONDS
           
static Card TWO_OF_HEARTS
           
static Card TWO_OF_SPADES
           
 
Fields inherited from interface wyvern.lib.classes.games.card.CardConstants
ACE, CLUBS, DIAMONDS, EIGHT, FIVE, FLUSH, FOUR, FOUR_OF_A_KIND, FULL_HOUSE, HEARTS, JACK, KING, NINE, NOTHING, NUM_FACES, NUM_SUITS, ONE_PAIR, QUEEN, ROYAL_FLUSH, SEVEN, SIX, SPADES, STRAIGHT, STRAIGHT_FLUSH, TEN, THREE, THREE_OF_A_KIND, TWO, TWO_PAIR
 
Method Summary
 boolean equals(java.lang.Object obj)
          Returns true if the cards are equal (same face and suit).
static Card[] getAllCards()
          Returns a newly-instantiated array of all 52 cards, unshuffled.
static Card getCard(Face face, Suit suit)
          Returns the Card with the specified Face and Suit.
 Face getFace()
          Returns the Face.
 int getFaceNumber()
          Returns the face number (1-13)
 int getFaceValue()
          Returns card face value (1-10)
 java.lang.String getName()
          Returns the name of this Card.
 Suit getSuit()
          Returns the Suit.
 int getSuitNumber()
          Returns the suit number (0-3)
 int hashCode()
          Returns a hashcode for the card.
static void main(java.lang.String[] args)
          Misc testing functions.
 java.lang.String toString()
          Returns the name of the card.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NUM_CARDS

public static final int NUM_CARDS
See Also:
Constant Field Values

ACE_OF_HEARTS

public static final Card ACE_OF_HEARTS

ACE_OF_DIAMONDS

public static final Card ACE_OF_DIAMONDS

ACE_OF_CLUBS

public static final Card ACE_OF_CLUBS

ACE_OF_SPADES

public static final Card ACE_OF_SPADES

TWO_OF_HEARTS

public static final Card TWO_OF_HEARTS

TWO_OF_DIAMONDS

public static final Card TWO_OF_DIAMONDS

TWO_OF_CLUBS

public static final Card TWO_OF_CLUBS

TWO_OF_SPADES

public static final Card TWO_OF_SPADES

THREE_OF_HEARTS

public static final Card THREE_OF_HEARTS

THREE_OF_DIAMONDS

public static final Card THREE_OF_DIAMONDS

THREE_OF_CLUBS

public static final Card THREE_OF_CLUBS

THREE_OF_SPADES

public static final Card THREE_OF_SPADES

FOUR_OF_HEARTS

public static final Card FOUR_OF_HEARTS

FOUR_OF_DIAMONDS

public static final Card FOUR_OF_DIAMONDS

FOUR_OF_CLUBS

public static final Card FOUR_OF_CLUBS

FOUR_OF_SPADES

public static final Card FOUR_OF_SPADES

FIVE_OF_HEARTS

public static final Card FIVE_OF_HEARTS

FIVE_OF_DIAMONDS

public static final Card FIVE_OF_DIAMONDS

FIVE_OF_CLUBS

public static final Card FIVE_OF_CLUBS

FIVE_OF_SPADES

public static final Card FIVE_OF_SPADES

SIX_OF_HEARTS

public static final Card SIX_OF_HEARTS

SIX_OF_DIAMONDS

public static final Card SIX_OF_DIAMONDS

SIX_OF_CLUBS

public static final Card SIX_OF_CLUBS

SIX_OF_SPADES

public static final Card SIX_OF_SPADES

SEVEN_OF_HEARTS

public static final Card SEVEN_OF_HEARTS

SEVEN_OF_DIAMONDS

public static final Card SEVEN_OF_DIAMONDS

SEVEN_OF_CLUBS

public static final Card SEVEN_OF_CLUBS

SEVEN_OF_SPADES

public static final Card SEVEN_OF_SPADES

EIGHT_OF_HEARTS

public static final Card EIGHT_OF_HEARTS

EIGHT_OF_DIAMONDS

public static final Card EIGHT_OF_DIAMONDS

EIGHT_OF_CLUBS

public static final Card EIGHT_OF_CLUBS

EIGHT_OF_SPADES

public static final Card EIGHT_OF_SPADES

NINE_OF_HEARTS

public static final Card NINE_OF_HEARTS

NINE_OF_DIAMONDS

public static final Card NINE_OF_DIAMONDS

NINE_OF_CLUBS

public static final Card NINE_OF_CLUBS

NINE_OF_SPADES

public static final Card NINE_OF_SPADES

TEN_OF_HEARTS

public static final Card TEN_OF_HEARTS

TEN_OF_DIAMONDS

public static final Card TEN_OF_DIAMONDS

TEN_OF_CLUBS

public static final Card TEN_OF_CLUBS

TEN_OF_SPADES

public static final Card TEN_OF_SPADES

JACK_OF_HEARTS

public static final Card JACK_OF_HEARTS

JACK_OF_DIAMONDS

public static final Card JACK_OF_DIAMONDS

JACK_OF_CLUBS

public static final Card JACK_OF_CLUBS

JACK_OF_SPADES

public static final Card JACK_OF_SPADES

QUEEN_OF_HEARTS

public static final Card QUEEN_OF_HEARTS

QUEEN_OF_DIAMONDS

public static final Card QUEEN_OF_DIAMONDS

QUEEN_OF_CLUBS

public static final Card QUEEN_OF_CLUBS

QUEEN_OF_SPADES

public static final Card QUEEN_OF_SPADES

KING_OF_HEARTS

public static final Card KING_OF_HEARTS

KING_OF_DIAMONDS

public static final Card KING_OF_DIAMONDS

KING_OF_CLUBS

public static final Card KING_OF_CLUBS

KING_OF_SPADES

public static final Card KING_OF_SPADES
Method Detail

getName

public java.lang.String getName()
Returns the name of this Card.

Returns:
something like "Ace of Spaces" or "Ten of Clubs"

toString

public java.lang.String toString()
Returns the name of the card.


getFace

public Face getFace()
Returns the Face.


getSuit

public Suit getSuit()
Returns the Suit.


getFaceNumber

public int getFaceNumber()
Returns the face number (1-13)

Returns:
the face number: Ace=1, Two=2, ..., King=13

getFaceValue

public int getFaceValue()
Returns card face value (1-10)


getSuitNumber

public int getSuitNumber()
Returns the suit number (0-3)

Returns:
0 for Hearts, 1 for Diamonds, 2 for Clubs, 3 for Spades

getCard

public static Card getCard(Face face,
                           Suit suit)
Returns the Card with the specified Face and Suit.


getAllCards

public static Card[] getAllCards()
Returns a newly-instantiated array of all 52 cards, unshuffled.


equals

public boolean equals(java.lang.Object obj)
Returns true if the cards are equal (same face and suit).

Parameters:
obj - the object to compare to
Returns:
true if this is the same object instance as the passed object. In other words, returns (this == obj), which is acceptable because this class is a typesafe enum.

hashCode

public int hashCode()
Returns a hashcode for the card. Required since we overrode equals(). Also, we want the same hashcode for Cards across jvm sessions, and want to be able to ensure the hashcodes are unique and spread out nicely.


main

public static void main(java.lang.String[] args)
Misc testing functions.