Class Deck

java.lang.Object
me.ramendev.expokert.Deck

public class Deck extends Object
The standard 52-card deck, with an option to include a Wildcard.
  • Field Details

    • DEFAULT_DECK_SIZE

      public static final int DEFAULT_DECK_SIZE
      The default deck size, which is 52, or the number of possible permutations of Pips (excluding the Pip.WILD) and Suits (excluding the Suit.WILD).
  • Constructor Details

    • Deck

      public Deck(List<Card> cards)
      Constructor for a list of Cards from the provided List.
      Parameters:
      cards - The list of cards for this deck to hold.
    • Deck

      public Deck()
      Constructor for an empty deck of Cards.
    • Deck

      public Deck(Optional<Wildcard> wildcard)
      Constructor for a standard 52-Card deck, with the option to add a Wildcard. Note that in most decks, there will only be one wildcard present.
      Parameters:
      wildcard - The (Optional) wildcard to add to the deck.
    • Deck

      public Deck(String cards)
      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

      public String toString()
      Returns the string form of this deck. More formally, returns a string that is a result of String.join(CharSequence, CharSequence...)ing the cards' string forms, separated by spaces.
      Overrides:
      toString in class Object
      Returns:
      The string form of this deck.
    • getSize

      public int getSize()
      Returns how many cards are in this deck.
      Returns:
      The size of the set containing cards.
      See Also:
    • addCard

      public void addCard(Card card)
      Adds the given Card to 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

      public Card popCard()
      "Pops" the card (similar to the pop operation in the Stack or Deque data structure). Formally, removes the top card in the deck (or "last" when referring to LinkedHashSets) 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: