public class Card
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
ACE |
static int |
CLUBS |
static int |
DIAMONDS |
static int |
HEARTS |
static int |
JACK |
static int |
JOKER |
static int |
KING |
static int |
QUEEN |
static int |
SPADES |
Constructor and Description |
---|
Card()
Creates a Joker, with 1 as the associated value.
|
Card(int theValue,
int theSuit)
Creates a card with a specified suit and value.
|
Modifier and Type | Method and Description |
---|---|
int |
getSuit()
Returns the suit of this card.
|
java.lang.String |
getSuitAsString()
Returns a String representation of the card's suit.
|
int |
getValue()
Returns the value of this card.
|
java.lang.String |
getValueAsString()
Returns a String representation of the card's value.
|
java.lang.String |
toString()
Returns a string representation of this card, including both
its suit and its value (except that for a Joker with value 1,
the return value is just "Joker").
|
public static final int SPADES
public static final int HEARTS
public static final int DIAMONDS
public static final int CLUBS
public static final int JOKER
public static final int ACE
public static final int JACK
public static final int QUEEN
public static final int KING
public Card()
public Card(int theValue, int theSuit)
theValue
- the value of the new card. For a regular card (non-joker),
the value must be in the range 1 through 13, with 1 representing an Ace.
You can use the constants Card.ACE, Card.JACK, Card.QUEEN, and Card.KING.
For a Joker, the value can be anything.theSuit
- the suit of the new card. This must be one of the values
Card.SPADES, Card.HEARTS, Card.DIAMONDS, Card.CLUBS, or Card.JOKER.java.lang.IllegalArgumentException
- if the parameter values are not in the
permissible rangespublic int getSuit()
public int getValue()
public java.lang.String getSuitAsString()
public java.lang.String getValueAsString()
public java.lang.String toString()
toString
in class java.lang.Object