program4
Class Player

java.lang.Object
  extended by program4.Player

public class Player
extends java.lang.Object

Title: The Player Class

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

Copyright: Copyright (c) 2010

Author:
F. Graham

Field Summary
private  Hand hand
           
private  java.lang.String name
           
private  int points
           
 
Constructor Summary
Player(java.lang.String n)
          Parameterized constructor
 
Method Summary
 void addCard(GoFishCard card)
          Adds a card to the hand
 void addCards(java.util.LinkedList<GoFishCard> otherHand)
          Adds a LinkList of Cards to the hand
 java.util.LinkedList<GoFishCard> getCard(int rank)
          Returns the cards of a specified rank as a Linkedlist
 GoFishCard getCardAt(int index)
          returns the card at a specified index in the hand
 java.util.LinkedList<GoFishCard> getCards(int rank)
          Returns all of the cards of the specified rank as a LinkedList
 java.lang.String getName()
          Returns the player's name
 int getPoints()
          Returns the number of books the player has
 int getTotalCards()
          Returns the number of cards the player has
 boolean hasRank(int rank)
          Returns true if the player has a specified rank
 void setHand(Hand hand)
          Sets the hand
 void setName(java.lang.String name)
          Sets the name
 java.lang.String showHand()
          Returns the string representation of the hand
 java.lang.String toString()
          Returns the string representation of the player
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

private java.lang.String name

hand

private Hand hand

points

private int points
Constructor Detail

Player

public Player(java.lang.String n)
Parameterized constructor

Parameters:
n - - the name of the player
Method Detail

getName

public java.lang.String getName()
Returns the player's name

Returns:
- the player's name

setName

public void setName(java.lang.String name)
Sets the name

Parameters:
name - - the new value for name

getCards

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

Parameters:
rank - - the rank to search for
Returns:
- the cards of the specified rank as a LinkedList

setHand

public void setHand(Hand hand)
Sets the hand

Parameters:
hand -

getPoints

public int getPoints()
Returns the number of books the player has

Returns:
the number of books the player has

toString

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

Overrides:
toString in class java.lang.Object
Returns:
the string representation of the player

showHand

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

Returns:
the string representation of the hand

hasRank

public boolean hasRank(int rank)
Returns true if the player has a specified rank

Parameters:
rank - - the rank to search for
Returns:
- Returns true if the player has a specified rank, false otherwise

addCard

public void addCard(GoFishCard card)
Adds a card to the hand

Parameters:
card - - the card to add

addCards

public void addCards(java.util.LinkedList<GoFishCard> otherHand)
Adds a LinkList of Cards to the hand

Parameters:
otherHand - - the LinkedList of cards

getCardAt

public GoFishCard getCardAt(int index)
returns the card at a specified index in the hand

Parameters:
index - - the position of the card
Returns:
- the card at that position

getTotalCards

public int getTotalCards()
Returns the number of cards the player has

Returns:
Return the number of cards the player has

getCard

public java.util.LinkedList<GoFishCard> getCard(int rank)
Returns the cards of a specified rank as a Linkedlist

Parameters:
rank - - the rank to search for
Returns:
- the Linked List of cards