common
Class Card

java.lang.Object
  extended by common.Card
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable

public class Card
extends java.lang.Object
implements java.lang.Comparable, java.io.Serializable

See Also:
Serialized Form

Field Summary
static int ACE
          Indicates a card is an ace.
static int CLUBS
          Indicates that the card is a club.
static int DIAMONDS
          Indicates the the card is a diamond.
static int HEARTS
          Indicates the card is a heart.
static int JACK
          Indicates a card is a jack.
static int KING
          Indicates card is a king.
static int QUEEN
          Indicates a card is a queen.
static int SPADES
          Indicates the card is a spade.
 
Constructor Summary
Card(int cardVal, int cardSuit)
          Constructs a card with the specified value and suit.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compares two card objects on the basis of card value w/o consideration of suit.
 boolean equals(java.lang.Object o)
          Compares this card and another object.
 int getBlackjackValue()
          Returns the numerical value of what the card is worth in blackjack.
 javax.swing.ImageIcon getImage()
          Retrieves the picture file for this particular card.
 java.lang.String getSuit()
          Returns a String representing the card's suit.
 int getSuitAsInt()
          Returns an int representing the card's suit.
 int getValue()
          Returns an int representation this card's value.
 java.lang.String getValueAsString()
          Returns an int representing the card's value.
 java.lang.String toString()
          Return a String representation of this card, such as "10 of Hearts" or "Queen of Spades".
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CLUBS

public static final int CLUBS
Indicates that the card is a club.

See Also:
Constant Field Values

DIAMONDS

public static final int DIAMONDS
Indicates the the card is a diamond.

See Also:
Constant Field Values

SPADES

public static final int SPADES
Indicates the card is a spade.

See Also:
Constant Field Values

HEARTS

public static final int HEARTS
Indicates the card is a heart.

See Also:
Constant Field Values

ACE

public static final int ACE
Indicates a card is an ace.

See Also:
Constant Field Values

JACK

public static final int JACK
Indicates a card is a jack.

See Also:
Constant Field Values

QUEEN

public static final int QUEEN
Indicates a card is a queen.

See Also:
Constant Field Values

KING

public static final int KING
Indicates card is a king.

See Also:
Constant Field Values
Constructor Detail

Card

public Card(int cardVal,
            int cardSuit)
Constructs a card with the specified value and suit.

Parameters:
cardVal - int Value of the card
cardSuit - int Suit of the card.
Method Detail

getImage

public javax.swing.ImageIcon getImage()
Retrieves the picture file for this particular card.

Returns:
The image file for this card.

getSuit

public java.lang.String getSuit()
Returns a String representing the card's suit. Returns "Error" if not one of the 4 suits.

Returns:
String

getSuitAsInt

public int getSuitAsInt()
Returns an int representing the card's suit.

Returns:
int

getValue

public int getValue()
Returns an int representation this card's value.

Returns:
int

getValueAsString

public java.lang.String getValueAsString()
Returns an int representing the card's value. Returns "Error" if not one of the 4 suits.

Returns:
String

equals

public boolean equals(java.lang.Object o)
Compares this card and another object. If other object is a Card and they have the same suit and value, returns true. False otherwise.

Overrides:
equals in class java.lang.Object
Parameters:
o - Object
Returns:
boolean

toString

public java.lang.String toString()
Return a String representation of this card, such as "10 of Hearts" or "Queen of Spades". Overrides the toString() method of Object.

Overrides:
toString in class java.lang.Object
Returns:
String

getBlackjackValue

public int getBlackjackValue()
Returns the numerical value of what the card is worth in blackjack.

Returns:
int

compareTo

public int compareTo(java.lang.Object o)
Compares two card objects on the basis of card value w/o consideration of suit. Returns 0 if equal, 1 if this card is higher in value or an Ace, -1 otherwise. Note: Aces are considered to have the highest value.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - Object that this object is being compared to.
Returns:
int