|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgame.model.Card
public class Card
The Card class is used to represent cards in the deck. The cards have a suit and a rank and are initialized as such
Field Summary | |
---|---|
static int |
ACE
|
static int |
CLUBS
|
static int |
DIAMONDS
|
static int |
HEARTS
|
static int |
JACK
|
static int |
KING
|
static int |
QUEEN
|
private java.lang.Integer |
rank
|
static int |
SPADES
|
private java.lang.String |
suit
|
Constructor Summary | |
---|---|
Card()
A default constructor with rank 0 and unsuited. |
|
Card(int both)
|
|
Card(java.lang.Integer suit,
java.lang.Integer rank)
Constructor with an int representation of the suit |
|
Card(java.lang.String cardString)
This constructor constructs a card out of just a string. |
|
Card(java.lang.String suit,
java.lang.Integer rank)
This is the constructor most often used to create a card with a given suit and rank. |
Method Summary | |
---|---|
java.lang.Integer |
getRank()
Returns the rank of the Card |
java.lang.String |
getSuit()
Returns the suit of the Card |
int |
getSuitAsInt()
Returns the suit of the Card as int |
private java.lang.String |
printRank()
Returns a human readable rank from the rank integer. |
private java.lang.String |
printSuit()
Returns the first character of the suit in lower case. |
int |
toInt()
Returns an human easy recognizible int representation of the card. |
java.lang.String |
toString()
Returns a human readable String representation of the Card given by the rank then the first character of the suit. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private java.lang.Integer rank
private java.lang.String suit
public static final int DIAMONDS
public static final int HEARTS
public static final int SPADES
public static final int CLUBS
public static final int JACK
public static final int QUEEN
public static final int KING
public static final int ACE
Constructor Detail |
---|
public Card()
public Card(java.lang.String suit, java.lang.Integer rank)
suit
- The String representation of a playing card suitrank
- The Integer representation of the card rank.public Card(java.lang.Integer suit, java.lang.Integer rank)
suit
- The Integer representation of a playing card suitrank
- The Integer representation of the card rank.public Card(java.lang.String cardString)
cardString
- A String representation of the cardpublic Card(int both)
Method Detail |
---|
public java.lang.Integer getRank()
public java.lang.String getSuit()
public int getSuitAsInt()
public java.lang.String toString()
toString
in class java.lang.Object
public int toInt()
private java.lang.String printSuit()
private java.lang.String printRank()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |