|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectca.ualberta.cs.poker.Card
public class Card
Represents a playing card from a set of cards {0..51} which map to cards having a suit {0..3} <==> {CLUBS,DIAMONDS,HEARTS,SPADES} 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 | |
---|---|
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)
|
int |
getSuit()
Obtain the suit of this card |
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 |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int CLUBS
public static final int DIAMONDS
public static final int HEARTS
public static final int SPADES
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 int getIndex()
public void setIndex(int index)
index
- the new index of the cardpublic static 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 int getRank()
public static int getRank(int i)
public int getSuit()
public java.lang.String toString()
toString
in class java.lang.Object
public static char getRankChar(int r)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |