Package javatro.core
Class HoldingHand
java.lang.Object
javatro.core.HoldingHand
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a Card to the Hand.Discards a set number of cards.voidDraws a specified number of cards from the deck and adds them to the Hand.getHand()Retrieves the list of cards in the player's hand.Returns the specified cards as requested by the player Hand will then draw the same number of cards back from the deckvoidvoidsetHOLDINGLIMIT(int holdingLimit) Change the HOLDING_LIMIT of the HoldingHand Class.voidSorts the hand first by rank (Ace > King > Queen > ...voidSorts the hand first by suit (Spades > Hearts > Clubs > Diamonds), then by rank (Ace > King > Queen > ...
-
Field Details
-
Hand
-
-
Constructor Details
-
HoldingHand
public HoldingHand()Instantiate an empty List of Cards.
-
-
Method Details
-
add
Adds a Card to the Hand.This function should not be called if Hand size >= HOLDING_LIMIT
- Throws:
JavatroException
-
draw
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 deckdeck- Deck containing the remaining cards- Throws:
JavatroException
-
play
Returns the specified cards as requested by the player Hand will then draw the same number of cards back from the deckThis function should not be called if there are no cards played.
- Parameters:
cardsToPlay- List containing cards to be played- Throws:
JavatroException
-
discard
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
Retrieves the list of cards in the player's hand.- Returns:
- A
ListofCardobjects representing the player's hand.
-
setHand
-
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
-