|
-footer | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectgarrettsmith.playingcards.CardContainer
public class CardContainer
Represents a collection of cards, typically comprised of one or more decks.
| Constructor Summary | |
|---|---|
CardContainer(CardList cards)
Creates an unshuffled container with its cards equal to the contents of cards |
|
CardContainer(Deck deck)
Creates a shuffled container with its cards set to those of one deck. |
|
CardContainer(Deck deck,
int numDecks)
Creates a shuffled container with cards from numDecks
number of decks. |
|
CardContainer(Deck deck,
int numDecks,
boolean shuffle)
Creates a container with cards from numDecks
number of decks; will be shuffled according to the value of
shuffle. |
|
| Method Summary | |
|---|---|
Card |
getCard()
Removes and returns a single card from the container. |
boolean |
hasMoreCards()
Returns whether this container has any cards left in it. |
boolean |
isAutoResetOn()
Returns whether or not auto reset is on. |
boolean |
isEmpty()
Returns whether this container is empty. |
int |
originalSize()
Returns the original size of this container. |
void |
reset()
Resets this container with the original number and distribution of cards; does not re-shuffle (randomly re-order) the container and does not return the cards to their original order. |
void |
resetShuffle()
Resets this container with the original number and type distribution of cards and re-shuffles (randomly re-orders) the cards. |
void |
setAutoReset(double percentage)
Turns on auto reset, where the container is automatically reset AND reshuffled (radomly re-ordered) whenever the number of undealt cards falls below percentage percent the original number. |
void |
setAutoReset(int limit)
Turns on auto reset, where the container is automatically reset AND reshuffled (radomly re-ordered) whenever the number of undealt cards falls below limit. |
void |
setAutoResetOff()
Turns off auto reset. |
void |
shuffle()
Shuffles (randomly orders) the contents of the container. |
int |
size()
Returns the number of undealt cards in the container |
java.lang.String |
toString()
Returns a string representation of this container. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public CardContainer(Deck deck)
deck.
deck -
public CardContainer(Deck deck,
int numDecks)
numDecks
number of decks.
public CardContainer(Deck deck,
int numDecks,
boolean shuffle)
numDecks
number of decks; will be shuffled according to the value of
shuffle.
public CardContainer(CardList cards)
cards.
| Method Detail |
|---|
public boolean isAutoResetOn()
true if auto reset is on, false if
not.public Card getCard()
NoMoreCardsException - if there are no more cards in the container and
auto reset is not on.public boolean hasMoreCards()
true if the container has at least one card in it,
false if not.public boolean isEmpty()
true if the container is empty, false
if not.public void reset()
public void resetShuffle()
public int originalSize()
public int size()
public void setAutoReset(double percentage)
Turns on auto reset, where the container is automatically reset AND
reshuffled (radomly re-ordered) whenever the number of undealt cards
falls below percentage percent the original number.
If this method is invoked after setAutoReset( int ),
auto reset will still be on but will use a percentage threshold rather
than threshold based on the absolute number of cards remaining.
percentage - the percent undealt cards left that must be reached
before the deck is reset and reshuffled. Must be
greater than 0 and less than or equal to 1.0.public void setAutoReset(int limit)
Turns on auto reset, where the container is automatically reset AND
reshuffled (radomly re-ordered) whenever the number of undealt cards
falls below limit.
If this method is invoked after setAutoReset(double), auto reset will still be
on but will be triggered by the number of cards limit rather than a
percentage limit.
limit - the number of undealt cards that the container that must have
less than before the container is reset and reshuffled.public void setAutoResetOff()
setAutoReset( int ),
setAutoReset( double )public void shuffle()
Shuffles (randomly orders) the contents of the container.
This will not reset the container; only the undealt cards will be shuffled.
Use resetShuffle() to both reset and shuffle the container.
public java.lang.String toString()
toString in class java.lang.Object
|
-footer | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||