|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpoker.Card
public final class Card
Represents a playing card from a set of cards {0..51} which map to cards having a suit {0..3} <==> {SPADES,HEARTS,DIAMONDS,CLUBS} and a face value {0..12} <==> {2..ACE}
Field Summary | |
---|---|
static int |
ACE
|
static int |
BAD_CARD
|
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 |
NUM_CARDS
|
static int |
NUM_RANKS
|
static int |
NUM_SUITS
|
static int |
QUEEN
|
static int |
SEVEN
|
static int |
SIX
|
static int |
SPADES
|
static int |
TEN
|
static int |
THREE
|
static int |
TWO
|
Constructor Summary | |
---|---|
Card()
Constructor -- makes an empty card. |
|
Card(char rank,
char suit)
Constructor. |
|
Card(int index)
Constructor. |
|
Card(int rank,
int suit)
Constructor. |
|
Card(java.lang.String s)
|
Method Summary | |
---|---|
boolean |
equals(Card c)
|
int |
getIndex()
Return the integer index for this card. |
int |
getRank()
Obtain the rank of this card |
static int |
getRank(int i)
Obtain the rank of this card |
static char |
getRankChar(int r)
|
static int |
getRankFromChar(char rank)
|
int |
getSuit()
Obtain the suit of this card |
static int |
getSuit(int i)
Obtain the suit of this card |
static char |
getSuitChar(int s)
Given an integer suit value {0...3}, returns a character representation of it {h,d,c,s} |
static int |
getSuitFromChar(char suit)
Converts a suit character into its integer representation. |
void |
setCard(int rank,
int suit)
Change this card to another. |
void |
setIndex(int index)
Change the index of the card. |
static int |
toIndex(int rank,
int suit)
convert a rank and a suit to an index |
java.lang.String |
toString()
Obtain a String representation of this Card |
boolean |
valid()
Test if the card is valid. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int SPADES
public static final int HEARTS
public static final int DIAMONDS
public static final int CLUBS
public static final int BAD_CARD
public static final int TWO
public static final int THREE
public static final int FOUR
public static final int FIVE
public static final int SIX
public static final int SEVEN
public static final int EIGHT
public static final int NINE
public static final int TEN
public static final int JACK
public static final int QUEEN
public static final int KING
public static final int ACE
public static final int NUM_SUITS
public static final int NUM_RANKS
public static final int NUM_CARDS
Constructor Detail |
---|
public Card()
public Card(int rank, int suit)
rank
- face value of the cardsuit
- suit of the cardpublic Card(int index)
index
- integer index of card between 0 and 51public Card(java.lang.String s)
public Card(char rank, char suit)
rank
- the character representing the card's ranksuit
- the character representing the card's suitMethod Detail |
---|
public boolean equals(Card c)
public final int getIndex()
public void setIndex(int index)
index
- the new index of the cardpublic static final int toIndex(int rank, int suit)
rank
- the rank to convertsuit
- the suit to convert
public void setCard(int rank, int suit)
rank
- face value of the cardsuit
- suit of the cardpublic final int getRank()
public static final int getRank(int i)
public static final int getSuit(int i)
public final int getSuit()
public java.lang.String toString()
toString
in class java.lang.Object
public static int getRankFromChar(char rank)
public static int getSuitFromChar(char suit)
suit
- the suit character to convert
public static char getRankChar(int r)
public static char getSuitChar(int s)
public boolean valid()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |