-footer

garrettsmith.blackjack
Class Hand

java.lang.Object
  extended by garrettsmith.blackjack.Hand

public class Hand
extends java.lang.Object

Represents a player's hand of cards.

Since:
Blackjack v1.0
Version:
Blackjack v1.0
Author:
Garrett Smith, gsmith at northwestern dot edu

Method Summary
 int getBestValue()
          Returns the highest hand value without busting, if possible.
 CardList getCards()
          Returns the player's cards that represent this hand.
 Card getDealerCard()
          Returns the card that the dealer displays to the players.
 int getDealerValue()
          Calculates the value of the dealer's card assuming an ace is worth 1.
 int getValue()
          Returns the value of the hand assuming all aces are worth 1.
 double getWager()
          Returns the amount that was bet on this hand.
 boolean isBusted()
          Returns whether this hand has gone over 21.
 boolean isDoubleDownAllowed()
          Returns whether a double down is allowed at this point in the game.
 boolean isHitAllowed()
          Returns whether a hit is allowed at this point in the hand.
 boolean isMoveAllowed(Move move)
          Returns whether move is allowed at this point in the game.
 boolean isSoft()
          Tells whether the hand is soft.
 boolean isSplitAllowed()
          Returns whether a split is allowed at this point in the hand.
 boolean isStandAllowed()
          Returns whether standing is allowed at this point in the game.
 boolean isSurrenderAllowed()
          Returns whether a surrender is allowed.
 java.lang.String toString()
          Returns the state of this hand as a human-readable String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getBestValue

public int getBestValue()
Returns the highest hand value without busting, if possible. For example, a hand with a nine and an ace is scored as 20, but a hand with a nine, five, and an ace is worth 15.

See Also:
getValue()

getValue

public int getValue()
Returns the value of the hand assuming all aces are worth 1.

Returns:
the value of the hand assuming any aces are worth 1
See Also:
getBestValue()

getCards

public CardList getCards()
Returns the player's cards that represent this hand.

Returns:
a List of Card objects
See Also:
Card

getDealerCard

public Card getDealerCard()
Returns the card that the dealer displays to the players.

Returns:
corresponding to the card that the dealer displays to the players.

getDealerValue

public int getDealerValue()
Calculates the value of the dealer's card assuming an ace is worth 1.

Returns:
the value of the dealer's card assuming an ace is worth 1

isBusted

public boolean isBusted()
Returns whether this hand has gone over 21.


isDoubleDownAllowed

public boolean isDoubleDownAllowed()
Returns whether a double down is allowed at this point in the game.

Returns:
true if a double down is allowed, false if not

isStandAllowed

public boolean isStandAllowed()
Returns whether standing is allowed at this point in the game.


getWager

public double getWager()
Returns the amount that was bet on this hand.


isMoveAllowed

public boolean isMoveAllowed(Move move)
Returns whether move is allowed at this point in the game.


isHitAllowed

public boolean isHitAllowed()
Returns whether a hit is allowed at this point in the hand.

Returns:
true if a hit is allowed, false if not

isSoft

public boolean isSoft()
Tells whether the hand is soft. A soft hand is where one of the cards in the hand is an ace and where ace may take the value of 1 or 11 without causing the total value of the hand to exceed 21.

Returns:
true if the hand is soft, false if not

isSplitAllowed

public boolean isSplitAllowed()
Returns whether a split is allowed at this point in the hand.

Returns:
true if a split is allowed, false if not

toString

public java.lang.String toString()
Returns the state of this hand as a human-readable String.

Overrides:
toString in class java.lang.Object

isSurrenderAllowed

public boolean isSurrenderAllowed()
Returns whether a surrender is allowed.

Returns:
true if a surrender is allowed, false if not

-footer

Copyright 2001-5 Garrett Smith. Use is subject to license terms.