Creates a new, empty deck.
Adds a card to the bottom of the deck.
It is not required that the card have previously been drawn from
the deck. If copies
is defined, then that many copies are added,
all identical.
the card to add to the deck
the optional number of copies to add to the deck (default is 1)
Removes and returns the first card from the deck. To return the card to the bottom of the deck, discard it. If the deck is empty, returns null.
the top card, which is removed from the deck, or null if the deck is empty
Searches the deck for the first card matched by the specified function. If found, it removes it from the deck and returns it. If no matching card is found, returns null.
a function that takes a card and returns true if it is the type of card that should be drawn
the first matching card, which is removed from the deck
Returns a card from the deck without removing it. If index
is not defined, then the card at the top of the deck is returned.
Otherwise, if index
is 0 or positive, then the card at position
index
is returned, where a position of 0 is the top of the deck,
1 is the next card from the top, and so on. If index
is negative,
then the cards are counted from the bottom of the deck:
-1 is the last card, -2 is the penultimate card, and so on.
the position of the card to peek at within the deck
the card at the index, or the card at index size() + index
if the index is negative
the optional position of the card to remove from the deck
the removed card
Shuffles the cards in a deck into a random order.
Returns the number of cards currently in this deck.
Returns a string consisting of a comma separated list of the cards in this card deck.
A CardDeck simulates a deck of cards.