Class Card

java.lang.Object
  |
  +--Card
All Implemented Interfaces:
Comparable

public class Card
extends Object
implements Comparable

This class represents a playing card. Cards have a suit and a value


Field Summary
static int ACE
           
static int CLUBS
           
static int DIAMONDS
           
static int EIGHT
           
static int FIVE
           
static int FOUR
           
static int HEARTS
           
static int JACK
           
static int KING
           
static int NINE
           
static int QUEEN
           
static int SEVEN
           
static int SIX
           
static int SPADES
           
static int TEN
           
static int THREE
           
static int TWO
           
 
Constructor Summary
Card()
          Default constructor pre: none
post: getValue() = TWO getSuit() = CLUBS
Card(int value, int suit)
          pre: TWO <= value <= ACE,
CLUBS <= suit <= SPADES post: getValue() = value getSuit() = suit
 
Method Summary
 int compareTo(Object other)
           
 boolean equals(Object otherCard)
          pre: otherCard != null post: true iff two cards have same suit and value
 int getSuit()
          pre: none
post: returns cards Suit
 int getValue()
          *pre: none
post: returns cards Value
 String toString()
          pre: none
post: returns String with cards value and suit
 boolean validSuit(int suit)
           
 boolean validValue(int value)
          pre: none
post: returns true iff value between TWO and ACE inclusive
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ACE

public static final int ACE
See Also:
Constant Field Values

CLUBS

public static final int CLUBS
See Also:
Constant Field Values

DIAMONDS

public static final int DIAMONDS
See Also:
Constant Field Values

EIGHT

public static final int EIGHT
See Also:
Constant Field Values

FIVE

public static final int FIVE
See Also:
Constant Field Values

FOUR

public static final int FOUR
See Also:
Constant Field Values

HEARTS

public static final int HEARTS
See Also:
Constant Field Values

JACK

public static final int JACK
See Also:
Constant Field Values

KING

public static final int KING
See Also:
Constant Field Values

NINE

public static final int NINE
See Also:
Constant Field Values

QUEEN

public static final int QUEEN
See Also:
Constant Field Values

SEVEN

public static final int SEVEN
See Also:
Constant Field Values

SIX

public static final int SIX
See Also:
Constant Field Values

SPADES

public static final int SPADES
See Also:
Constant Field Values

TEN

public static final int TEN
See Also:
Constant Field Values

THREE

public static final int THREE
See Also:
Constant Field Values

TWO

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

Card

public Card()
Default constructor pre: none
post: getValue() = TWO getSuit() = CLUBS


Card

public Card(int value,
            int suit)
pre: TWO <= value <= ACE,
CLUBS <= suit <= SPADES post: getValue() = value getSuit() = suit

Method Detail

compareTo

public int compareTo(Object other)
Specified by:
compareTo in interface Comparable

equals

public boolean equals(Object otherCard)
pre: otherCard != null post: true iff two cards have same suit and value

Overrides:
equals in class Object

getSuit

public int getSuit()
pre: none
post: returns cards Suit


getValue

public int getValue()
*pre: none
post: returns cards Value


toString

public String toString()
pre: none
post: returns String with cards value and suit

Overrides:
toString in class Object

validSuit

public boolean validSuit(int suit)

validValue

public boolean validValue(int value)
pre: none
post: returns true iff value between TWO and ACE inclusive



Generated by BlueJ