glassfrog.handevaluator
Class EvaluateHand

java.lang.Object
  extended by glassfrog.handevaluator.EvaluateHand

public class EvaluateHand
extends java.lang.Object

Stores a Hand of Cards (up to a maximum of 7)

Author:
Aaron Davidson

Field Summary
private  int[] cards
           
static int MAX_CARDS
           
 
Constructor Summary
EvaluateHand()
           
EvaluateHand(EvaluateHand h)
          Duplicate an existing hand.
EvaluateHand(java.lang.String cs)
           
 
Method Summary
 boolean addCard(EvaluateCard c)
          Add a card to the hand.
 boolean addCard(int i)
          Add a card to the hand.
 EvaluateCard getCard(int pos)
          Get the a specified card in the hand
 int[] getCardArray()
          Obtain the array of card indexes for this hand.
 int getCardIndex(int pos)
          Get the specified card id
 void makeEmpty()
          Remove the all cards from the hand.
 void removeCard()
          Remove the last card in the hand.
 void setCard(int pos, EvaluateCard c)
          Add a card to the hand.
 int size()
          Get the size of the hand.
 void sort()
          Bubble Sort the hand to have cards in descending order, but card index.
 java.lang.String toString()
          Get a string representation of this Hand.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_CARDS

public static final int MAX_CARDS
See Also:
Constant Field Values

cards

private int[] cards
Constructor Detail

EvaluateHand

public EvaluateHand()

EvaluateHand

public EvaluateHand(java.lang.String cs)
Parameters:
cs - A string representing a Hand of cards

EvaluateHand

public EvaluateHand(EvaluateHand h)
Duplicate an existing hand.

Parameters:
h - the hand to clone.
Method Detail

size

public int size()
Get the size of the hand.

Returns:
the number of cards in the hand

removeCard

public void removeCard()
Remove the last card in the hand.


makeEmpty

public void makeEmpty()
Remove the all cards from the hand.


addCard

public boolean addCard(EvaluateCard c)
Add a card to the hand. (if there is room)

Parameters:
c - the card to add
Returns:
true if the card was added, false otherwise

addCard

public boolean addCard(int i)
Add a card to the hand. (if there is room)

Parameters:
i - the index value of the card to add
Returns:
true if the card was added, false otherwise

getCard

public EvaluateCard getCard(int pos)
Get the a specified card in the hand

Parameters:
pos - the position (1..n) of the card in the hand
Returns:
the card at position pos

setCard

public void setCard(int pos,
                    EvaluateCard c)
Add a card to the hand. (if there is room)

Parameters:
c - the card to add

getCardArray

public int[] getCardArray()
Obtain the array of card indexes for this hand. First element contains the size of the hand.

Returns:
array of card indexs (size = MAX_CARDS+1)

sort

public void sort()
Bubble Sort the hand to have cards in descending order, but card index. Used for database indexing.


toString

public java.lang.String toString()
Get a string representation of this Hand.

Overrides:
toString in class java.lang.Object

getCardIndex

public int getCardIndex(int pos)
Get the specified card id

Parameters:
pos - the position (1..n) of the card in the hand
Returns:
the card at position pos