java.lang.Object
polimi.ingsw.am21.codex.model.Cards.Commons.Deck<T>

public class Deck<T> extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deck(List<T> cards)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the number of cards left in the deck
    Draws a card from the deck
    draw(int n)
    Draws a card from the deck
    void
    insert(T card)
    Inserts a card in the bottom of the deck
    Lets you peek the top card of the deck, without removing it
    void
    Shuffles the deck

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Deck

      public Deck(List<T> cards)
      Parameters:
      cards - list of cards
  • Method Details

    • shuffle

      public void shuffle()
      Shuffles the deck
    • draw

      public T draw() throws EmptyDeckException
      Draws a card from the deck
      Returns:
      the card drawn
      Throws:
      EmptyDeckException
    • draw

      public List<T> draw(int n) throws EmptyDeckException
      Draws a card from the deck
      Parameters:
      n - number of cards to draw
      Returns:
      the list of drawn cards
      Throws:
      EmptyDeckException
    • cardsLeft

      public int cardsLeft()
      Returns the number of cards left in the deck
    • insert

      public void insert(T card)
      Inserts a card in the bottom of the deck
      Parameters:
      card - the card to insert
    • peek

      public T peek()
      Lets you peek the top card of the deck, without removing it
      Returns:
      The top card of the deck