|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object | +--cardgame.Deck
The Deck class represents a deck of cards which can be used for various kinds of card games. It implements a shuffle method that can put the deck in a random order. It provides methods to deal the cards out to players and to keep track of the number of cards dealt and remaining.
| Field Summary | |
private java.lang.String |
deckBackImageFileName
The private variable deckBackImageFileName stores the file name that represents the back of each PlayingCard in a Deck. |
private int |
numberOfCards
The private variable numberOfCards represents the initial number of cards in a Deck. |
private int |
numberOfDecks
The private variable numberOfDecks represents the number of standard decks in a Deck. |
private java.util.Stack |
stack
The private variable stack is a java Stack (which extends Vector) that stores all PlayingCards created for a Deck. |
private boolean |
standardDeck
The private variable standardDeck indicates whether a Deck is a standard deck or not. |
| Constructor Summary | |
Deck()
The no-argument constructor creates a single standard deck with 52 cards. |
|
Deck(boolean standard)
This constructor allows for the creation of non-standard decks of cards; e.g., decks of less than 52 cards. |
|
Deck(int deckMultiple)
This constructor creates a deck composed of multiples of a standard deck. |
|
| Method Summary | |
void |
addPlayingCard(PlayingCard cardToBeAdded)
The public method addPlayingCard aids in creating non-standard decks. |
void |
buildStandardDeck()
The public method buildStandardDeck assembles a standard Deck of 52 PlayingCards. |
PlayingCard |
dealPlayingCard()
The public method dealPlayingCard simulates the dealing of a card from the top of the deck. |
int |
getCardsDealt()
The public method getCardsDealt returns the current number of cards that have been dealt from a Deck. |
int |
getCardsLeft()
The public method getCardsLeft returns the current number of cards that are left in a Deck. |
java.lang.String |
getDeckBackImageFileName()
The public method getDeckBackImageFileName specifies a file name containing an image to use when constructing all of a Deck's PlayingCards. |
java.lang.String |
getDeckState()
The public method getDeckState returns a useful String representation of the current state of a Deck. |
int |
getNumberOfCards()
The public method getNumberOfCards returns the initial number of cards that a Deck had when created. |
int |
getNumberOfDecks()
The public method getNumberOfDecks indicates the number of decks created by a Deck constructor. |
boolean |
getStandardDeck()
The public method getStandardDeck indicates whether a Deck is a standard deck or not. |
void |
setDeckBackImageFileName(java.lang.String deckBackImageFile)
The public method setDeckBackImageFileName specifies a file name containing an image to use when constructing all of a Deck's PlayingCards. |
void |
shuffle()
The public method shuffle reorders the PlayingCards in a Deck to be in random order. |
java.lang.String |
toString()
The public method toString returns a complete specification of a Deck's current state in a convenient tagged format. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
private java.util.Stack stack
shuffle(),
dealPlayingCard()private int numberOfCards
getNumberOfCards()private int numberOfDecks
getNumberOfDecks()private boolean standardDeck
getStandardDeck()private java.lang.String deckBackImageFileName
getDeckBackImageFileName(),
setDeckBackImageFileName(String deckBackImageFile)| Constructor Detail |
public Deck()
buildStandardDeck()public Deck(int deckMultiple)
deckMultiple - the number of decks as an int.numberOfDecks,
getNumberOfDecks(),
buildStandardDeck()public Deck(boolean standard)
standard - true for standard, false for non-standard.addPlayingCard(PlayingCard cardToBeAdded)| Method Detail |
public int getNumberOfCards()
numberOfCardspublic int getCardsDealt()
public int getCardsLeft()
public void shuffle()
VectorRandomizer,
RandomIntGeneratorpublic PlayingCard dealPlayingCard()
stackpublic void buildStandardDeck()
stack,
Deck(),
Deck(int deckMultiple),
Deck(boolean standard),
setDeckBackImageFileName(String deckBackImageFile)public void addPlayingCard(PlayingCard cardToBeAdded)
cardToBeAdded - the PlayingCard to be added to a Deck.Deck(boolean standard)public int getNumberOfDecks()
numberOfDecks,
Deck(int deckMultiple)public boolean getStandardDeck()
standardDeckpublic java.lang.String getDeckBackImageFileName()
deckBackImageFileName,
setDeckBackImageFileName(String deckBackImageFile)public void setDeckBackImageFileName(java.lang.String deckBackImageFile)
deckBackImageFile - the String value of the back image file name.deckBackImageFileName,
getDeckBackImageFileName()public java.lang.String getDeckState()
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||