Class Deck<T extends Card>

java.lang.Object
it.polimi.ingsw.am13.model.Deck<T>
Type Parameters:
T - A subclass of Card

public class Deck<T extends Card> extends Object
This class represent a physical deck of cards
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final LinkedList<T>
    This attribute represents a deck using a LinkedList
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deck(LinkedList<T> deck)
    This is the constructor of a Deck
  • Method Summary

    Modifier and Type
    Method
    Description
    Draws the Card at the top of this deck.
    int
    Returns the number of remaining cards in this deck.
    Retrieves a copy of the first card of this deck without removing it.
    boolean
    Checks if this deck is empty.
    void
    Shuffles this deck randomly, and sets visibility of the new top card

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • deck

      private final LinkedList<T extends Card> deck
      This attribute represents a deck using a LinkedList
  • Constructor Details

    • Deck

      public Deck(LinkedList<T> 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

      public T draw() throws InvalidDrawCardException
      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

      public T getTop() throws InvalidDrawCardException
      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.