|
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||
java.lang.Object | +--Hand
Represents the basic functionality of a hand of cards.
Extensions of this class will provide the
definition of what constitutes a hand for that game and how hands are compared
to one another by overriding the compareTo method.
| Constructor Summary | |
Hand()
|
|
| Method Summary | |
void |
addCard(Card card)
Adds a card to this hand. |
int |
compareTo(java.lang.Object otherHandObject)
Compares two hands. |
boolean |
containsCard(Card card)
Determines whether or not the hand contains the specified card. |
void |
discardHand()
Removes all the cards from the hand, leaving an empty hand. |
abstract int |
evaluateHand()
Evaluates the hand. |
int |
findCard(Card card)
Searches for the first instance of the specified card in the hand. |
Card |
getCard(int index)
Obtains the card stored at the specified location in the hand. |
int |
getNumberOfCards()
The number of cards held in the hand. |
boolean |
isEmpty()
Checks to see if the hand is empty. |
Card |
removeCard(Card card)
Removes the specified card from the current hand. |
Card |
removeCard(int index)
Removes the card at the specified index from the hand. |
boolean |
replaceCard(Card oldCard,
Card replacementCard)
Replaces the specified card with another card. |
void |
sort()
Sorts the card in the hand. |
java.lang.String |
toString()
Returns a description of the hand. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public Hand()
| Method Detail |
public void addCard(Card card)
card - card to be added to the current hand.public Card getCard(int index)
index - position of card to be accessed.public Card removeCard(Card card)
card - the card to be removed.public Card removeCard(int index)
index - poisition of the card to be removed.public void discardHand()
public int getNumberOfCards()
public void sort()
Card class.public boolean isEmpty()
true is the hand is empty.public boolean containsCard(Card card)
card - the card being searched for in the hand.true if the card is present in the hand.public int findCard(Card card)
card - card being searched for.-1 if not found.public int compareTo(java.lang.Object otherHandObject)
compareTo in interface java.lang.ComparableotherHandObject - the hand being compared.public abstract int evaluateHand()
public java.lang.String toString()
toString in class java.lang.Object
public boolean replaceCard(Card oldCard,
Card replacementCard)
true if the replacement occurs.
|
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||