Class Card

java.lang.Object
  extended by Card
Direct Known Subclasses:
GameCard

public class Card
extends java.lang.Object

Represents a playing card. Bugs: none known


Field Summary
static int CLUBS
           
static int DIAMONDS
           
static int HEARTS
           
static int SPADES
           
 
Constructor Summary
Card(int face, int suit)
          Constructs a Card object with the given face value and suit value.
 
Method Summary
 int getFace()
          Returns the face value of the card.
 int getSuit()
          Returns the suit of the card.
 java.lang.String toString()
          Returns a String representation of a Card object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

HEARTS

public static final int HEARTS
See Also:
Constant Field Values

DIAMONDS

public static final int DIAMONDS
See Also:
Constant Field Values

CLUBS

public static final int CLUBS
See Also:
Constant Field Values

SPADES

public static final int SPADES
See Also:
Constant Field Values
Constructor Detail

Card

public Card(int face,
            int suit)
Constructs a Card object with the given face value and suit value. The face value of the card is set to 1 if an invalid face value is given; the suit of the card is set to HEARTS if an invalid suit is given.

Parameters:
face - the face value of the card
suit - the suit of the card
Method Detail

getFace

public int getFace()
Returns the face value of the card.

Returns:
face value of the card (between 1 and 13, inclusive)

getSuit

public int getSuit()
Returns the suit of the card.

Returns:
suit of the card (HEARTS, DIAMONDS, CLUBS, or SPADES)

toString

public java.lang.String toString()
Returns a String representation of a Card object. The string has the format "ffs" where ff is the face value (padded with a space, if necessary) and s is the suit.

Overrides:
toString in class java.lang.Object
Returns:
a String representation of a Card object