blackjackanalyst
Class Hand

java.lang.Object
  extended by blackjackanalyst.Hand
Direct Known Subclasses:
PlayerHand

public class Hand
extends java.lang.Object

A hand of cards.

Author:
Michael Parker

Method Summary
 java.util.List<Card> getCards()
          Returns a list containing the cards in the hand, appearing in the order in which they were added.
 int getHighValidValue()
          Returns the highest possible value that can be made from the hand, but does not exceed 21.
 int getHighValue()
          Returns the highest possible value that can be made from the hand.
 int getLowValue()
          Returns the lowest possible value that can be made from the hand.
 java.util.Set<java.lang.Integer> getValues()
          Returns all possible values that can be made from the hand, where values appear in ascending order.
 boolean isBlackjack()
          Returns whether the current hand is a blackjack, which is an ace and a ten-valued card.
 boolean isBusted()
          Returns whether the hand has busted, meaning that the smallest possible hand value is greater than 21.
 boolean isFinished()
          Returns whether this hand is finished.
 boolean isSoft()
          Returns whether the hand is soft, meaning that it has not busted and whether the highest value that does not exceed 21 contains an ace valued as 11.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getCards

public java.util.List<Card> getCards()
Returns a list containing the cards in the hand, appearing in the order in which they were added. The returned list may not be modified.

Returns:
the list of cards in the hand

getHighValidValue

public int getHighValidValue()
Returns the highest possible value that can be made from the hand, but does not exceed 21. If no such value exists, meaning that this hand has busted, this method returns -1.

Returns:
the highest possible hand value not exceeding 21

getLowValue

public int getLowValue()
Returns the lowest possible value that can be made from the hand. This value may exceed 21.

Returns:
the lowest possible hand value

getHighValue

public int getHighValue()
Returns the highest possible value that can be made from the hand. This value may exceed 21.

Returns:
the highest possible hand value

getValues

public java.util.Set<java.lang.Integer> getValues()
Returns all possible values that can be made from the hand, where values appear in ascending order.

Returns:
all possible hand values

isBusted

public boolean isBusted()
Returns whether the hand has busted, meaning that the smallest possible hand value is greater than 21.

Returns:
true if the hand has busted, false otherwise

isBlackjack

public boolean isBlackjack()
Returns whether the current hand is a blackjack, which is an ace and a ten-valued card.

Returns:
true if the hand is a blackjack, false otherwise

isSoft

public boolean isSoft()
Returns whether the hand is soft, meaning that it has not busted and whether the highest value that does not exceed 21 contains an ace valued as 11.

Returns:
true if the hand is soft, false otherwise

isFinished

public boolean isFinished()
Returns whether this hand is finished. The hand is finished if the player or dealer has stood or busted, or if the player has doubled down and received his or her final card.

Returns:
true if the hand is finished, false otherwise

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object