glassfrog.model
Class Hand

java.lang.Object
  extended by glassfrog.model.Hand
All Implemented Interfaces:
java.io.Serializable

public class Hand
extends java.lang.Object
implements java.io.Serializable

The Hand class is used to represent a set of cards for the players and the board. More specifically, a Hand is the set of all the private cards for all of the players over all of the rounds and the set of public cards for all of the rounds. Use: To store hands dealt from the deck and give string representations of those hands for evaluation.

Author:
jdavidso
See Also:
Serialized Form

Field Summary
private  int numPlayers
           
private  int[] numPrivateCards
           
private  int[] numPublicCards
           
private  int numRounds
           
private  java.util.ArrayList<Card>[][] privateCards
           
private  java.util.ArrayList<Card>[] publicCards
           
 
Constructor Summary
Hand()
          Default constructor.
Hand(int numPlayers, int numRounds, java.util.ArrayList<Card>[] publicCards, java.util.ArrayList<Card>[][] privateCards)
          Used to preset a hand with given cards
Hand(int numPlayers, int numRounds, int[] numPrivateCards, int[] numPublicCards)
          Good constructor.
 
Method Summary
 java.lang.String boardToString()
          Returns the board cards for a given hand, space delimited.
 java.lang.String getEvaluationString(int player)
          Return the hand for the given player (only thier private cards) and all public cards.
 java.util.ArrayList<Card> getPrivateCards(int player, int round)
          Return the private cards for a player for the given hand in a given round
 java.lang.String getPrivateCardsString(int player, int round)
          Return the cards for a player for a given round
 java.util.ArrayList<Card> getPublicCards(int round)
          Return the public cards for a given round
 java.lang.String getPublicCardsString(int round)
          Return the public cards for a given round
private  void initializeCardArrays()
          Initializes the public and private card arrays with to the proper sizes
 void setPrivateCards(java.util.ArrayList<Card>[][] privateCards)
          Set the private cards for a specific player
 void setPublicCards(java.util.ArrayList<Card>[] publicCards)
          Set the public card array for the hand
 java.lang.String toString()
          Override of the toString method for easy to read hand representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

numRounds

private int numRounds

numPlayers

private int numPlayers

numPrivateCards

private int[] numPrivateCards

numPublicCards

private int[] numPublicCards

publicCards

private java.util.ArrayList<Card>[] publicCards

privateCards

private java.util.ArrayList<Card>[][] privateCards
Constructor Detail

Hand

public Hand()
Default constructor. Not really intened for use.


Hand

public Hand(int numPlayers,
            int numRounds,
            int[] numPrivateCards,
            int[] numPublicCards)
Good constructor. Takes in the number of players, rounds, private and public cards and initializes the arrays and numbers for holding and displaying the Hand information.

Parameters:
numPlayers -
numRounds -
numPrivateCards -
numPublicCards -

Hand

public Hand(int numPlayers,
            int numRounds,
            java.util.ArrayList<Card>[] publicCards,
            java.util.ArrayList<Card>[][] privateCards)
Used to preset a hand with given cards

Parameters:
numPlayers -
numRounds -
publicCards -
privateCards -
Method Detail

getPublicCards

public java.util.ArrayList<Card> getPublicCards(int round)
Return the public cards for a given round

Parameters:
round - an int representing the round to return the public cards for
Returns:
an @ArrayList of @Cards for the given round

setPublicCards

public void setPublicCards(java.util.ArrayList<Card>[] publicCards)
Set the public card array for the hand

Parameters:
publicCards - an @ArrayList of @Cards that represents the public cards for the hand

getPrivateCards

public java.util.ArrayList<Card> getPrivateCards(int player,
                                                 int round)
Return the private cards for a player for the given hand in a given round

Parameters:
player - an int representing the seat of the player to return the cards to
round - an int representing the round the private cards came from
Returns:
an @ArrayList of @Cards for the player and round specified

setPrivateCards

public void setPrivateCards(java.util.ArrayList<Card>[][] privateCards)
Set the private cards for a specific player

Parameters:
privateCards - an @ArrayList of @Cards representing the players private cards

initializeCardArrays

private void initializeCardArrays()
Initializes the public and private card arrays with to the proper sizes


toString

public java.lang.String toString()
Override of the toString method for easy to read hand representation.

Overrides:
toString in class java.lang.Object
Returns:
an easy to read representation of the hand

getEvaluationString

public java.lang.String getEvaluationString(int player)
Return the hand for the given player (only thier private cards) and all public cards. This is used to be passed to the hand evaluation class.

Parameters:
player - An integer representing the index of the player for the hand
Returns:
A string formatted for the hand evaluation class

boardToString

public java.lang.String boardToString()
Returns the board cards for a given hand, space delimited.

Returns:
A string representing the board cards

getPrivateCardsString

public java.lang.String getPrivateCardsString(int player,
                                              int round)
Return the cards for a player for a given round

Parameters:
player - An integer representation of the player for the index
round - An integer representation of the round for the index
Returns:
A string representing the private cards for a given player/round

getPublicCardsString

public java.lang.String getPublicCardsString(int round)
Return the public cards for a given round

Parameters:
round - An integer representation of a round for the index
Returns:
A string representing the public cards for a specified round