Package javatro.core

Class HoldingHand

java.lang.Object
javatro.core.HoldingHand

public class HoldingHand extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Instantiate an empty List of Cards.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(Card cardToAdd)
    Adds a Card to the Hand.
    discard(List<Integer> cardsToDiscard)
    Discards a set number of cards.
    void
    draw(int numberOfDraws, Deck deck)
    Draws a specified number of cards from the deck and adds them to the Hand.
    Retrieves the list of cards in the player's hand.
    play(List<Integer> cardsToPlay)
    Returns the specified cards as requested by the player Hand will then draw the same number of cards back from the deck
    void
    setHand(List<Card> hand)
     
    void
    setHOLDINGLIMIT(int holdingLimit)
    Change the HOLDING_LIMIT of the HoldingHand Class.
    void
    Sorts the hand first by rank (Ace > King > Queen > ...
    void
    Sorts the hand first by suit (Spades > Hearts > Clubs > Diamonds), then by rank (Ace > King > Queen > ...

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • HoldingHand

      public HoldingHand()
      Instantiate an empty List of Cards.
  • Method Details

    • add

      public void add(Card cardToAdd) throws JavatroException
      Adds a Card to the Hand.

      This function should not be called if Hand size >= HOLDING_LIMIT

      Throws:
      JavatroException
    • draw

      public void draw(int numberOfDraws, Deck deck) throws JavatroException
      Draws a specified number of cards from the deck and adds them to the Hand.
      Parameters:
      numberOfDraws - The number of cards to draw from the deck
      deck - Deck containing the remaining cards
      Throws:
      JavatroException
    • play

      public List<Card> play(List<Integer> cardsToPlay) throws JavatroException
      Returns the specified cards as requested by the player Hand will then draw the same number of cards back from the deck

      This function should not be called if there are no cards played.

      Parameters:
      cardsToPlay - List containing cards to be played
      Throws:
      JavatroException
    • discard

      public List<Card> discard(List<Integer> cardsToDiscard) throws JavatroException
      Discards a set number of cards. This function should not be used if the number of discards left is 0.
      Parameters:
      cardsToDiscard - List containing the cards at specified positions to be discarded
      Throws:
      JavatroException
    • sortBySuit

      public void sortBySuit()
      Sorts the hand first by suit (Spades > Hearts > Clubs > Diamonds), then by rank (Ace > King > Queen > ... > Two) within each suit.
    • sortByRank

      public void sortByRank()
      Sorts the hand first by rank (Ace > King > Queen > ... > Two), then by suit (Spades > Hearts > Clubs > Diamonds) within each rank.
    • getHand

      public List<Card> getHand()
      Retrieves the list of cards in the player's hand.
      Returns:
      A List of Card objects representing the player's hand.
    • setHand

      public void setHand(List<Card> hand)
    • setHOLDINGLIMIT

      public void setHOLDINGLIMIT(int holdingLimit)
      Change the HOLDING_LIMIT of the HoldingHand Class. This function is used when you need to manually change the HOLDING_LIMIT