program4
Class Hand

java.lang.Object
  extended by program4.Hand

public class Hand
extends java.lang.Object

Title: The Hand Class

Description: Defines the properties and behaviors of a GoFish Hand.

Copyright: Copyright (c) 2010

Author:
F. Graham

Field Summary
private  java.util.LinkedList<GoFishCard> hand
          LinkList of GoFish Cards
 
Constructor Summary
Hand()
          Default constructor
 
Method Summary
 int countRank(int rank)
          Counts the number of cards of a particular rank in the hand
 int evaluate()
          Returns 1 if a book (all 4 cards of a particular suit) is in the hand and removes the book from the hand
 java.util.LinkedList<GoFishCard> findRank(int rank)
          Finds and returns all cards of the specified rank
 GoFishCard getCardAt(int index)
          Returns the card at the specified position in this list.
 java.util.LinkedList<GoFishCard> getCards(int rank)
          Returns a list of cards of a specified rank
 int getCount()
          Returns the number of cards in the hand
 java.util.LinkedList<GoFishCard> getHand()
          Returns the hand as LinkedList of GoFish cards
 boolean hasRank(int rank)
          Returns true if this rank is the hand
 void insertByRank(GoFishCard card)
          Adds a Card to the hand, the hand is sorted by rank
 void insertHand(java.util.Collection<? extends GoFishCard> otherHand)
          Adds a LinkList of Cards to the hand, the hand is sorted by rank
 boolean isEmpty()
          Determines if the hand is empty
 java.lang.String toString()
          Returns a string representation of the hand
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

hand

private java.util.LinkedList<GoFishCard> hand
LinkList of GoFish Cards

Constructor Detail

Hand

public Hand()
Default constructor

Method Detail

getCount

public int getCount()
Returns the number of cards in the hand

Returns:
the number of cards in the hand

getHand

public java.util.LinkedList<GoFishCard> getHand()
Returns the hand as LinkedList of GoFish cards

Returns:
the hand as a LinkedList of GoFish Cards

hasRank

public boolean hasRank(int rank)
Returns true if this rank is the hand

Parameters:
rank - - the rank to search for
Returns:
Returns true if this rank is the hand,
false otherwise

toString

public java.lang.String toString()
Returns a string representation of the hand

Overrides:
toString in class java.lang.Object

findRank

public java.util.LinkedList<GoFishCard> findRank(int rank)
Finds and returns all cards of the specified rank

Parameters:
rank - - the rank to search for
Returns:
all of the cards of that rank as a LinkedList of GoFish Cards

insertByRank

public void insertByRank(GoFishCard card)
Adds a Card to the hand, the hand is sorted by rank

Parameters:
card - - a GoFish Card

insertHand

public void insertHand(java.util.Collection<? extends GoFishCard> otherHand)
Adds a LinkList of Cards to the hand, the hand is sorted by rank

Parameters:
otherHand - LinkedList of GoFish Cards

isEmpty

public boolean isEmpty()
Determines if the hand is empty

Returns:
- Returns true if the hand is empty, false otherwise

evaluate

public int evaluate()
Returns 1 if a book (all 4 cards of a particular suit) is in the hand and removes the book from the hand

Returns:
the number of books (all 4 cards of a particular suit) in the hand

countRank

public int countRank(int rank)
Counts the number of cards of a particular rank in the hand

Parameters:
rank - - the rank to count
Returns:
the number of cards of that rank

getCardAt

public GoFishCard getCardAt(int index)
Returns the card at the specified position in this list.

Parameters:
index - the index of the list
Returns:

getCards

public java.util.LinkedList<GoFishCard> getCards(int rank)
Returns a list of cards of a specified rank

Parameters:
rank - - the rank to search for
Returns:
the cards as LinkedList of GoFish Cards