Package me.ramendev.expokert
Class Deck
java.lang.Object
me.ramendev.expokert.Deck
The standard 52-card deck, with an option to include a
Wildcard.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
DEFAULT_DECK_SIZE
public static final int DEFAULT_DECK_SIZE
-
-
Constructor Details
-
Deck
- Parameters:
cards- The list of cards for this deck to hold.
-
Deck
public Deck()Constructor for an empty deck ofCards. -
Deck
Constructor for a standard 52-Carddeck, with the option to add aWildcard. Note that in most decks, there will only be one wildcard present.- Parameters:
wildcard- The (Optional) wildcard to add to the deck.
-
Deck
Constructor for a deck generated from a list of whitespace-separated cards.- Parameters:
cards- The string of cards to generate the deck from.
-
-
Method Details
-
toString
Returns the string form of this deck. More formally, returns a string that is a result ofString.join(CharSequence, CharSequence...)ing the cards' string forms, separated by spaces. -
getSize
public int getSize()Returns how many cards are in this deck.- Returns:
- The size of the set containing cards.
- See Also:
-
addCard
Adds the givenCardto the deck.- Parameters:
card- The card to add to the deck.- Throws:
DeckSizeException- When the deck is already full.DuplicateCardException- When the card being added already has a duplicate in the list.
-
popCard
"Pops" the card (similar to the pop operation in theStackorDequedata structure). Formally, removes the top card in the deck (or "last" when referring toLinkedHashSets) and returns it.- Returns:
- The card at the top of the deck.
- Throws:
DeckSizeException- When the deck is empty, meaning there is no cards. to pop from it.- See Also:
-