-footer

garrettsmith.blackjack.refimpl
Class TextPlayer

java.lang.Object
  extended by garrettsmith.blackjack.refimpl.TextPlayer
All Implemented Interfaces:
EventHandler

public class TextPlayer
extends java.lang.Object
implements EventHandler

Provides for playing Blackjack via the console. Use argument --help for command line parameter use.

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

Method Summary
 void fatalErrorOccurred(java.lang.Exception e)
          This method is invoked when an error occurs that prevents the game from completing.
 void handFinished(Hand hand, double gainOrLoss, Result result, CardList dealerCards)
          Method that is invoked when a hand is done being played.
static void main(java.lang.String[] arguments)
           Plays blackjack via the console.
 boolean offerEarlySurrender(Hand hand)
          Invoked when early surrender is offered; this method then prompts the user.
 boolean offerInsurance(Hand hand)
          Invoked when insurance if available; always returns false.
 Move offerRegularTurn(Hand hand)
          Method invoked when the player is offered a turn.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

main

public static void main(java.lang.String[] arguments)

Plays blackjack via the console. Use argument --help for command line parameter usage.


offerInsurance

public boolean offerInsurance(Hand hand)
Invoked when insurance if available; always returns false.


offerEarlySurrender

public boolean offerEarlySurrender(Hand hand)
Invoked when early surrender is offered; this method then prompts the user.

Specified by:
offerEarlySurrender in interface EventHandler
Parameters:
hand - the hand for which early surrender is being offered
Returns:
true if the user wishes to surrender; false otherwise

offerRegularTurn

public Move offerRegularTurn(Hand hand)
Description copied from interface: EventHandler
Method invoked when the player is offered a turn. The implementor returns the appropriate Move they wish to make.

Specified by:
offerRegularTurn in interface EventHandler
Parameters:
hand - the hand for which a turn is being offered
Returns:
the Move the player whishes to make

fatalErrorOccurred

public void fatalErrorOccurred(java.lang.Exception e)
Description copied from interface: EventHandler
This method is invoked when an error occurs that prevents the game from completing.

Specified by:
fatalErrorOccurred in interface EventHandler
Parameters:
e - the exception that caused the error

handFinished

public void handFinished(Hand hand,
                         double gainOrLoss,
                         Result result,
                         CardList dealerCards)
Description copied from interface: EventHandler
Method that is invoked when a hand is done being played. Note that if a hand is split there may be multiple hands for each game played.

Specified by:
handFinished in interface EventHandler
Parameters:
hand - the hand which has completed the game
gainOrLoss - the winnings from the hand; negative if the wager was lost
result - the result of the hand; see Result
dealerCards - the cards that the dealer ended the hand with

-footer

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