Package model
Class Deck
java.lang.Object
model.Deck
Holds multiple Card objects and performs operations such as shuffling
the deck.
This class is responsible for creating a deck, populating it with 52 cards, shuffling the deck, adding cards to the deck, removing a card from the deck, checking if the deck has any cards left, emptying the deck, and returning the deck's current size.
- Author:
- Michael Neuper michael@michaelneuper.com
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDeprecated.voidintvoidgetCards()booleanhasCards()voidpopulate()voidreloadDeckFromDiscard(Deck discard) Take all cards from discarded deck and place them in this deck, shuffled.voidshuffle()takeCard()toString()Returns a String representation of the Deck object.
-
Constructor Details
-
Deck
public Deck()Constructs a new emptyDeckobject.
-
-
Method Details
-
populate
public void populate() -
shuffle
public void shuffle() -
addCard
Deprecated.- Parameters:
inCard- theCardthe be added to the deck
-
takeCard
- Returns:
- the
Cardthat was removed
-
hasCards
public boolean hasCards() -
emptyDeck
public void emptyDeck() -
addCards
-
getCards
-
reloadDeckFromDiscard
Take all cards from discarded deck and place them in this deck, shuffled. Clear the old deck.- Parameters:
discard- the deck cards are coming from
-
cardsLeft
public int cardsLeft()- Returns:
- number of cards left in the deck.
-
toString
Returns a String representation of the Deck object. The String contains a list of all the cards in the deck, with each card on a new line.
-