java.lang.Object
it.polimi.ingsw.am13.model.Deck<T>
- Type Parameters:
T
- A subclass ofCard
This class represent a physical deck of cards
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final LinkedList
<T> This attribute represents a deck using a LinkedList -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondraw()
Draws the Card at the top of this deck.int
getSize()
Returns the number of remaining cards in this deck.getTop()
Retrieves a copy of the first card of this deck without removing it.boolean
isEmpty()
Checks if this deck is empty.void
shuffle()
Shuffles this deck randomly, and sets visibility of the new top card
-
Field Details
-
deck
This attribute represents a deck using a LinkedList
-
-
Constructor Details
-
Deck
This is the constructor of a Deck- Parameters:
deck
- LinkedList of the deck's cards
-
-
Method Details
-
shuffle
public void shuffle()Shuffles this deck randomly, and sets visibility of the new top card -
draw
Draws the Card at the top of this deck. Manages visibility of card drawn and new possible card visible- Returns:
- a subclass of
Card
- Throws:
InvalidDrawCardException
- if the deck is empty
-
getTop
Retrieves a copy of the first card of this deck without removing it. This method should not be used to carry out the game flow.- Returns:
- the first card of this deck
- Throws:
InvalidDrawCardException
- if the deck is empty
-
isEmpty
public boolean isEmpty()Checks if this deck is empty.- Returns:
true
if this deck is empty.
-
getSize
public int getSize()Returns the number of remaining cards in this deck.- Returns:
- the number of remaining cards in this deck.
-