wyvern.lib.classes.games.card
Class Hand

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

public class Hand
extends java.lang.Object
implements CardConstants

Represents a 5-card hand, which is an unordered set of 5 cards chosen from the standard deck of 52. Each of the 5 cards must have a unique combination of face and suit.

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

Field Summary
 
Fields inherited from interface wyvern.lib.classes.games.card.CardConstants
ACE, ACE_OF_CLUBS, ACE_OF_DIAMONDS, ACE_OF_HEARTS, ACE_OF_SPADES, CLUBS, DIAMONDS, EIGHT, EIGHT_OF_CLUBS, EIGHT_OF_DIAMONDS, EIGHT_OF_HEARTS, EIGHT_OF_SPADES, FIVE, FIVE_OF_CLUBS, FIVE_OF_DIAMONDS, FIVE_OF_HEARTS, FIVE_OF_SPADES, FLUSH, FOUR, FOUR_OF_A_KIND, FOUR_OF_CLUBS, FOUR_OF_DIAMONDS, FOUR_OF_HEARTS, FOUR_OF_SPADES, FULL_HOUSE, HEARTS, JACK, JACK_OF_CLUBS, JACK_OF_DIAMONDS, JACK_OF_HEARTS, JACK_OF_SPADES, KING, KING_OF_CLUBS, KING_OF_DIAMONDS, KING_OF_HEARTS, KING_OF_SPADES, NINE, NINE_OF_CLUBS, NINE_OF_DIAMONDS, NINE_OF_HEARTS, NINE_OF_SPADES, NOTHING, NUM_CARDS, NUM_FACES, NUM_SUITS, ONE_PAIR, QUEEN, QUEEN_OF_CLUBS, QUEEN_OF_DIAMONDS, QUEEN_OF_HEARTS, QUEEN_OF_SPADES, ROYAL_FLUSH, SEVEN, SEVEN_OF_CLUBS, SEVEN_OF_DIAMONDS, SEVEN_OF_HEARTS, SEVEN_OF_SPADES, SIX, SIX_OF_CLUBS, SIX_OF_DIAMONDS, SIX_OF_HEARTS, SIX_OF_SPADES, SPADES, STRAIGHT, STRAIGHT_FLUSH, TEN, TEN_OF_CLUBS, TEN_OF_DIAMONDS, TEN_OF_HEARTS, TEN_OF_SPADES, THREE, THREE_OF_A_KIND, THREE_OF_CLUBS, THREE_OF_DIAMONDS, THREE_OF_HEARTS, THREE_OF_SPADES, TWO, TWO_OF_CLUBS, TWO_OF_DIAMONDS, TWO_OF_HEARTS, TWO_OF_SPADES, TWO_PAIR
 
Constructor Summary
Hand(Card c1, Card c2, Card c3, Card c4, Card c5)
          Constructs a new Hand
 
Method Summary
protected  void analyze()
          Looks at the cards and determines what type of hand it is (nothing, one pair, two pair, three of a kind, etc.)
 boolean contains(Card card)
          Returns true if the hand contains the specified Card.
 boolean equals(java.lang.Object obj)
          Returns true if this Hand is equal to another one.
 HandType getType()
          Analyzes the hand and returns the type, e.g. straight flush.
 int hashCode()
          We overrode equals(), so we need to override hashcode().
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Hand

public Hand(Card c1,
            Card c2,
            Card c3,
            Card c4,
            Card c5)
Constructs a new Hand

Method Detail

analyze

protected void analyze()
Looks at the cards and determines what type of hand it is (nothing, one pair, two pair, three of a kind, etc.)


contains

public boolean contains(Card card)
Returns true if the hand contains the specified Card.

Parameters:
card - a Card object to check
Returns:
true if this hand contains that card

equals

public boolean equals(java.lang.Object obj)
Returns true if this Hand is equal to another one.


hashCode

public int hashCode()
We overrode equals(), so we need to override hashcode().


getType

public HandType getType()
Analyzes the hand and returns the type, e.g. straight flush.

Returns:
a HandType for this hand.