Package controller

Class Hand

java.lang.Object
controller.Hand

public class Hand extends Object
Contains methods to calculate the value of a hand, take cards from a deck and discard the hand to a deck.
Author:
Michael Neuper michael@michaelneuper.com
  • Constructor Details

    • Hand

      public Hand()
      Constructs a new empty Hand object.
  • Method Details

    • takeCardFromDeck

      public void takeCardFromDeck(Deck deck)
      Adds a Card from the Deck to the Hand.
      Parameters:
      deck - deck to take Cardfrom
    • calculateValue

      public int calculateValue()
      Calculates the value of a Hand.
      Returns:
      the value of a Hand
    • getCard

      public Card getCard(int i)
      Gets the Card at a specific index.
      Parameters:
      i - the index of the Card or get
      Returns:
      the Card at index i
    • getCardFilePath

      public String getCardFilePath(int i)
      Gets the relative file path of a Card.
      Parameters:
      i - index of the Cardin Hand
      Returns:
      file path of a Card at a specific index, if the index is out of range, a blank card is returned
    • discardHandToDeck

      public void discardHandToDeck(Deck discardDeck)
      Discards the current Hand and adds its cards to the specified discard Deck.
      Parameters:
      discardDeck - the deck to which the current Hand's Card will be added
    • toString

      public String toString()
      Returns a String representation of the current Hand.
      Overrides:
      toString in class Object
      Returns:
      a String representation of the current Hand