Package dev.davwheat
Class Deck
- java.lang.Object
-
- dev.davwheat.Deck
-
public class Deck extends java.lang.Object
Manages a deck of Cards, from generation to selection.
-
-
Constructor Summary
Constructors Constructor Description Deck()
-
Method Summary
Modifier and Type Method Description Deck
addCard(Card card)
Add a card to the Deck.static Deck
createBaseDeck()
Creates a Deck with the standard set of cards.Deck
lock()
Locks the Deck to prevent modifications.Deck
shuffleCards()
Shuffle all the cards.Card
takeCard()
Take the top card, return it, and move it to the bottom of the pile.
-
-
-
Method Detail
-
addCard
public Deck addCard(Card card) throws DeckIsLockedException
Add a card to the Deck. Will throw an exception if the Deck is locked.Returns the deck so that it can be chained: `.addCard(...).addCard(...)`
- Parameters:
card
- Card to be added- Returns:
- the Deck after the card has been added
- Throws:
DeckIsLockedException
- The Deck has been locked. No more modifications can be made.
-
lock
public Deck lock()
Locks the Deck to prevent modifications.This is a one-way process and cannot be reversed.
- Returns:
- the Deck
-
shuffleCards
public Deck shuffleCards()
Shuffle all the cards.- Returns:
- the Deck
-
takeCard
public Card takeCard()
Take the top card, return it, and move it to the bottom of the pile.- Returns:
- a Card
-
createBaseDeck
public static Deck createBaseDeck()
Creates a Deck with the standard set of cards.- Returns:
- the Deck
-
-