Class Card

java.lang.Object
  |
  +--Card
Direct Known Subclasses:
PlayingCard

public class Card
extends java.lang.Object

The Card class implements a basic card that can be used in various kinds of games. It represents the name, suit, and value of a card.

Version:
1.0, 3 July 2001
Author:
James A. Webb, mrjavahack@yahoo.com

Field Summary
static java.lang.String ACE
          This value represents the card name "Ace"
static java.lang.String CLUB
          This value represents the card suit "Club"
static java.lang.String DIAMOND
          This value represents the card suit "Diamond"
static java.lang.String EIGHT
          This value represents the card name "Eight"
static java.lang.String FIVE
          This value represents the card name "Five"
static java.lang.String FOUR
          This value represents the card name "Four"
static java.lang.String HEART
          This value represents the card suit "Heart"
static java.lang.String JACK
          This value represents the card name "Jack"
static java.lang.String KING
          This value represents the card name "King"
static java.lang.String NINE
          This value represents the card name "Nine"
static java.lang.String QUEEN
          This value represents the card name "Queen"
static java.lang.String SEVEN
          This value represents the card name "Seven"
static java.lang.String SIX
          This value represents the card name "Six"
static java.lang.String SPADE
          This value represents the card suit "Spade"
static java.lang.String TEN
          This value represents the card name "Ten"
static java.lang.String THREE
          This value represents the card name "Three"
static java.lang.String TWO
          This value represents the card name "Two"
 
Constructor Summary
Card()
          The no-argument constructor sets the Card's variables to default values.
Card(java.lang.String cardName, java.lang.String cardSuit)
          This basic constructor sets the Card's name and suit.
Card(java.lang.String cardName, java.lang.String cardSuit, int cardValue)
          This constructor sets all the Card's parameters: name, suit, and value.
 
Method Summary
 boolean equals(Card theOtherCard)
          The public method equals checks whether two Cards have the same name and suit, and returns a boolean result.
 java.lang.String getName()
          The public method getName returns the name of the Card.
 java.lang.String getSuit()
          The public method getSuit returns the suit of the Card.
 int getValue()
          The public method getValue returns the numeric value of the Card.
 void setName(java.lang.String cardName)
          The public method setName sets the name of the Card.
 void setSuit(java.lang.String cardSuit)
          The public method setSuit sets the suit of the Card.
 void setValue(int cardValue)
          The public method setValue sets the numeric value of the Card.
 java.lang.String toString()
          The public method toString returns the String representation of the Card, such as "Ace of Spades."
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ACE

public static final java.lang.String ACE
This value represents the card name "Ace"

TWO

public static final java.lang.String TWO
This value represents the card name "Two"

THREE

public static final java.lang.String THREE
This value represents the card name "Three"

FOUR

public static final java.lang.String FOUR
This value represents the card name "Four"

FIVE

public static final java.lang.String FIVE
This value represents the card name "Five"

SIX

public static final java.lang.String SIX
This value represents the card name "Six"

SEVEN

public static final java.lang.String SEVEN
This value represents the card name "Seven"

EIGHT

public static final java.lang.String EIGHT
This value represents the card name "Eight"

NINE

public static final java.lang.String NINE
This value represents the card name "Nine"

TEN

public static final java.lang.String TEN
This value represents the card name "Ten"

JACK

public static final java.lang.String JACK
This value represents the card name "Jack"

QUEEN

public static final java.lang.String QUEEN
This value represents the card name "Queen"

KING

public static final java.lang.String KING
This value represents the card name "King"

HEART

public static final java.lang.String HEART
This value represents the card suit "Heart"

SPADE

public static final java.lang.String SPADE
This value represents the card suit "Spade"

DIAMOND

public static final java.lang.String DIAMOND
This value represents the card suit "Diamond"

CLUB

public static final java.lang.String CLUB
This value represents the card suit "Club"
Constructor Detail

Card

public Card()
The no-argument constructor sets the Card's variables to default values.

Card

public Card(java.lang.String cardName,
            java.lang.String cardSuit)
This basic constructor sets the Card's name and suit.
Parameters:
cardName - the name of the Card as a String.
cardSuit - the suit of the Card as a String.

Card

public Card(java.lang.String cardName,
            java.lang.String cardSuit,
            int cardValue)
This constructor sets all the Card's parameters: name, suit, and value.
Parameters:
cardName - the name of the Card as a String.
cardSuit - the suit of the Card as a String.
cardValue - the value of the Card as an int.
Method Detail

getName

public java.lang.String getName()
The public method getName returns the name of the Card.
Returns:
the name of the Card as a String.

setName

public void setName(java.lang.String cardName)
The public method setName sets the name of the Card.
Parameters:
cardName - the name of the Card as a String.

getSuit

public java.lang.String getSuit()
The public method getSuit returns the suit of the Card.
Returns:
the suit of the Card as a String.

setSuit

public void setSuit(java.lang.String cardSuit)
The public method setSuit sets the suit of the Card.
Parameters:
cardSuit - the suit of the Card as a String.

getValue

public int getValue()
The public method getValue returns the numeric value of the Card.
Returns:
the value of the Card as an int.

setValue

public void setValue(int cardValue)
The public method setValue sets the numeric value of the Card.
Parameters:
cardValue - the numeric value of the Card as an int.

toString

public java.lang.String toString()
The public method toString returns the String representation of the Card, such as "Ace of Spades."
Overrides:
toString in class java.lang.Object
Returns:
the textual representation of the Card as a String.

equals

public boolean equals(Card theOtherCard)
The public method equals checks whether two Cards have the same name and suit, and returns a boolean result.
Parameters:
theOtherCard - - the Card to be compared with this Card.
Returns:
the boolean result of the comparison.