public class Hand
extends java.lang.Object
Constructor and Description |
---|
Hand()
Create a hand that is initially empty.
|
Modifier and Type | Method and Description |
---|---|
void |
addCard(Card c)
Add a card to the hand.
|
void |
clear()
Remove all cards from the hand, leaving it empty.
|
Card |
getCard(int position)
Gets the card in a specified position in the hand.
|
int |
getCardCount()
Returns the number of cards in the hand.
|
void |
removeCard(Card c)
Remove a card from the hand, if present.
|
void |
removeCard(int position)
Remove the coard in a specified position from the hand.
|
void |
sortBySuit()
Sorts the cards in the hand so that cards of the same suit are
grouped together, and within a suit the cards are sorted by value.
|
void |
sortByValue()
Sorts the cards in the hand so that cards are sorted into order
of increasing value.
|
public void clear()
public void addCard(Card c)
c
- the non-null card to be added.java.lang.NullPointerException
- if the parameter c is null.public void removeCard(Card c)
c
- the card to be removed. If c is null or if the card is not in
the hand, then nothing is done.public void removeCard(int position)
position
- the position of the card that is to be removed, where
positions are starting from zero.java.lang.IllegalArgumentException
- if the position does not exist in
the hand, that is if the position is less than 0 or greater than
or equal to the number of cards in the hand.public int getCardCount()
public Card getCard(int position)
position
- the position of the card that is to be returnedjava.lang.IllegalArgumentException
- if position does not exist in the handpublic void sortBySuit()
public void sortByValue()