blackjackanalyst
Class Card

java.lang.Object
  extended by blackjackanalyst.Card

public class Card
extends java.lang.Object

A card, specified by its rank and suit.

Author:
Michael Parker

Nested Class Summary
static class Card.Rank
          The rank of a card.
static class Card.Suit
          The suit of a card.
 
Field Summary
static int CARD_RANKS
          The number of card ranks.
static int CARD_SUITS
          The number of card suits.
static int CARDS_PER_DECK
          The number of cards per deck.
 
Method Summary
static Card getCard(Card.Rank _card_rank, Card.Suit _card_suit)
          Returns the Card object having the given suit and rank.
static Card getCard(int card_id)
          Returns the Card having the given unique numerical identifier.
 int getID()
          Returns the unique numerical identifier of this card.
 Card.Rank getRank()
          Returns the rank of this card.
 Card.Suit getSuit()
          Returns the suit of this card.
 int getValue()
          Returns the value of the card.
 boolean isAce()
          Returns whether this card is an ace.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CARD_SUITS

public static final int CARD_SUITS
The number of card suits.

See Also:
Constant Field Values

CARD_RANKS

public static final int CARD_RANKS
The number of card ranks.

See Also:
Constant Field Values

CARDS_PER_DECK

public static final int CARDS_PER_DECK
The number of cards per deck.

See Also:
Constant Field Values
Method Detail

getCard

public static Card getCard(Card.Rank _card_rank,
                           Card.Suit _card_suit)
Returns the Card object having the given suit and rank.

Parameters:
_card_rank - the rank of the card to retrieve
_card_suit - the suit of the card to retrieve
Returns:
the Card object having the given rank and suit

getCard

public static Card getCard(int card_id)
Returns the Card having the given unique numerical identifier.

Parameters:
card_id - the numerical identifier of the card
Returns:
the card having the given numerical identifier

getRank

public final Card.Rank getRank()
Returns the rank of this card.

Returns:
the card rank

getSuit

public final Card.Suit getSuit()
Returns the suit of this card.

Returns:
the card suit

getValue

public int getValue()
Returns the value of the card. If the rank of the card is an ace, this method returns 1.

Returns:
the value of the card

isAce

public boolean isAce()
Returns whether this card is an ace.

Returns:
true if this card is an ace, false otherwise

getID

public int getID()
Returns the unique numerical identifier of this card.

Returns:
the identifying card number

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object