|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectCard
public class Card
This Card class represents playing card. This class mainly has two attributes, those are Suit and Rank. When a Card object created, basically these two attibutes are assigned and and created. Basically, this class has been designed to fully feature card and its functions. In addition to this, a static function called newDeck() created a deck of cards and returns as an arraylist.
Nested Class Summary | |
---|---|
static class |
Card.Rank
Rank enum to name the card. |
static class |
Card.Suit
Suit enum to catogorise the card into main four types. |
Field Summary | |
---|---|
private static java.util.List<Card> |
protoDeck
|
private Card.Rank |
rank
|
private Card.Suit |
suit
|
Constructor Summary | |
---|---|
Card(Card.Suit suit,
Card.Rank rank)
constructor of this card class, receives card suit and rank to create a card object |
|
Card(java.lang.String card)
constructor of this card class, receives card suit and rank as a single strings to create a card object |
|
Card(java.lang.String suit,
java.lang.String rank)
constructor of this card class, receives card suit and rank strings to create a card object |
Method Summary | |
---|---|
java.lang.String |
getImageName()
returns the image name of a card which is saved in /resources/images/ |
static java.util.ArrayList<Card> |
newDeck()
Returns a deck of cards as Arraylist. |
Card.Rank |
rank()
returns rank of the card as Rank enum object. |
java.lang.String |
rank2string(Card.Rank rank)
This method is to convert a Rank object to its name as String |
Card.Rank |
string2rank(java.lang.String rank)
This method is to convert a String rank name to a real Rank object. |
Card.Suit |
string2suit(java.lang.String suit)
This method is to convert a String suit name to a real Suit object. |
Card.Suit |
suit()
returns suit of the card as Suit enum object. |
java.lang.String |
suit2string(Card.Suit suit)
This method is to convert a Suit object to its name as String |
java.lang.String |
toString()
returns a String value of a card. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private final Card.Suit suit
private final Card.Rank rank
private static final java.util.List<Card> protoDeck
Constructor Detail |
---|
public Card(Card.Suit suit, Card.Rank rank)
public Card(java.lang.String suit, java.lang.String rank)
suit
- a card suit's name as Stringrank
- a card rank's name as Stringpublic Card(java.lang.String card)
card
- a card suit's name and rank's name as a single String. Eg: JACK of HEARTSMethod Detail |
---|
public Card.Rank string2rank(java.lang.String rank)
rank
- name of a card rank as String
public Card.Suit string2suit(java.lang.String suit)
suit
- name of a card suit as String
public java.lang.String rank2string(Card.Rank rank)
rank
- Rank object of a card.
public java.lang.String suit2string(Card.Suit suit)
suit
- Suit object of a card.
public Card.Rank rank()
public Card.Suit suit()
public java.lang.String getImageName()
public java.lang.String toString()
toString
in class java.lang.Object
public static java.util.ArrayList<Card> newDeck()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |