-footer

garrettsmith.blackjack
Class Blackjack

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

public class Blackjack
extends java.lang.Object

Provides for playing a game of blackjack.

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

Constructor Summary
Blackjack()
          Creates a new Blackjack game simulator with the default Rules.
Blackjack(Rules rules)
          Creates a new Blackjack simulator with the specified Rules.
 
Method Summary
static int calculateBestValue(CardList cards)
          Calculates the highest possible value for a list of cards without busting, if possible.
static int calculateValue(Card card)
          Calculates the value of a playing card according to the rules of Blackjack; assumes all aces are worth 1.
static int calculateValue(CardList cards)
          Calculates the value of a list of cards according to the rules of Blackjack; assumes all aces are worth 1.
 Rules getRules()
          Returns the current Rules being used.
static boolean isBlackjack(CardList cards)
          Returns whether the list of cards passed in represents a blackjack.
static boolean isNonAceFaceCard(Card card)
          Returns whether the card passed in is a non-Ace face card: a ten, jack, queen, or king.
static boolean isSoft(CardList cards)
          Returns whether the list of cards is a soft hand.
 void playGame(EventHandler handler, double wager)
          Plays one game of blackjack betting wager and using handler to determine how the player's hand is played.
 void setRules(Rules rules)
          Sets the rules used to determine how the game is handled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Blackjack

public Blackjack()
Creates a new Blackjack game simulator with the default Rules.


Blackjack

public Blackjack(Rules rules)
Creates a new Blackjack simulator with the specified Rules.

Parameters:
rules - specifying which rules this simulator will follow
Method Detail

calculateBestValue

public static int calculateBestValue(CardList cards)
Calculates the highest possible value for a list of cards without busting, if possible.


calculateValue

public static int calculateValue(Card card)
Calculates the value of a playing card according to the rules of Blackjack; assumes all aces are worth 1.

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

calculateValue

public static int calculateValue(CardList cards)
Calculates the value of a list of cards according to the rules of Blackjack; assumes all aces are worth 1.


getRules

public Rules getRules()
Returns the current Rules being used.


isNonAceFaceCard

public static boolean isNonAceFaceCard(Card card)
Returns whether the card passed in is a non-Ace face card: a ten, jack, queen, or king.


isBlackjack

public static boolean isBlackjack(CardList cards)
Returns whether the list of cards passed in represents a blackjack. This method doesn't take into consideration whether these are the first cards dealt or the result of a split; in the latter case the cards are not a blackjack.


isSoft

public static boolean isSoft(CardList cards)
Returns whether the list of cards is a soft hand. That is, the list of cards contain an ace whose value could be 1 or 11 without exceeding 21.


playGame

public void playGame(EventHandler handler,
                     double wager)
Plays one game of blackjack betting wager and using handler to determine how the player's hand is played.


setRules

public void setRules(Rules rules)
Sets the rules used to determine how the game is handled.


-footer

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