com.gbayer.basicblackjack.ui
Class ConsoleUI

java.lang.Object
  extended by com.gbayer.basicblackjack.ui.ConsoleUI
All Implemented Interfaces:
UI

public class ConsoleUI
extends java.lang.Object
implements UI

An implementation of the UI interface for interacting with the user via stdin and stdout.


Field Summary
static int HIT_ACTION_KEY
          Constant - Key to select hit action.
static int INITIAL_ACTION_FLAG
          Constant - Flag to indicate initial action request.
static int MAX_ACTION_KEY
          Constant - Key to select last action.
static int MIN_ACTION_KEY
          Constant - Key to select first action.
static int QUIT_INDICATOR_BET
          Constant - The amount a user should bet to indicate a desire to stop playing.
static int STAY_ACTION_KEY
          Constant - Key to select stay action.
 
Constructor Summary
ConsoleUI()
          Instantiates a new console UI reading from stdin and writing to stdout.
ConsoleUI(java.io.InputStream in, java.io.PrintStream out)
          Instantiates a new console UI.
 
Method Summary
 void dealerWinsRound()
          Update UI to indicate that player wins the round
 void endRound()
          Update UI to indicate that the hand has ended.
 void exitMsg()
          Exit msg.
 Player.Action getUserActionChoice()
          Get user to choose an action.
 java.lang.String getUserInput()
          Gets the user's input.
 void introMsg()
          Intro msg.
 void playerActionTaken(Player player, Player.Action action)
          Update UI to indicate the action that was taken.
 void playerStatus(Player currentPlayer)
          Update status of players hand.
 void playerStatusWithCoveredCards(Player currentPlayer)
          Update status of players hand.
 void playerWinsRound()
          Update UI to indicate that player wins the round.
 void quitMessage()
          Quit message.
 void roundIsPush()
          Update UI to indicate that the round is a push.
 void takeBet(HumanPlayer currentPlayer)
          Get user to place a bet.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

QUIT_INDICATOR_BET

public static final int QUIT_INDICATOR_BET
Constant - The amount a user should bet to indicate a desire to stop playing.

See Also:
Constant Field Values

HIT_ACTION_KEY

public static final int HIT_ACTION_KEY
Constant - Key to select hit action.

See Also:
Constant Field Values

STAY_ACTION_KEY

public static final int STAY_ACTION_KEY
Constant - Key to select stay action.

See Also:
Constant Field Values

MIN_ACTION_KEY

public static final int MIN_ACTION_KEY
Constant - Key to select first action.

See Also:
Constant Field Values

MAX_ACTION_KEY

public static final int MAX_ACTION_KEY
Constant - Key to select last action.

See Also:
Constant Field Values

INITIAL_ACTION_FLAG

public static final int INITIAL_ACTION_FLAG
Constant - Flag to indicate initial action request.

See Also:
Constant Field Values
Constructor Detail

ConsoleUI

public ConsoleUI()
Instantiates a new console UI reading from stdin and writing to stdout.


ConsoleUI

public ConsoleUI(java.io.InputStream in,
                 java.io.PrintStream out)
Instantiates a new console UI.

Parameters:
out - the out
Method Detail

takeBet

public void takeBet(HumanPlayer currentPlayer)
             throws GameQuitException
Description copied from interface: UI
Get user to place a bet.

Specified by:
takeBet in interface UI
Parameters:
currentPlayer - the current player
Throws:
GameQuitException - the game quit exception

getUserActionChoice

public Player.Action getUserActionChoice()
Description copied from interface: UI
Get user to choose an action.

Specified by:
getUserActionChoice in interface UI
Returns:
the user action choice

getUserInput

public java.lang.String getUserInput()
Description copied from interface: UI
Gets the user's input.

Specified by:
getUserInput in interface UI
Returns:
the user input

playerStatus

public void playerStatus(Player currentPlayer)
Description copied from interface: UI
Update status of players hand.

Specified by:
playerStatus in interface UI
Parameters:
currentPlayer - the current player

playerStatusWithCoveredCards

public void playerStatusWithCoveredCards(Player currentPlayer)
Description copied from interface: UI
Update status of players hand. Keep all but the first card covered.

Specified by:
playerStatusWithCoveredCards in interface UI
Parameters:
currentPlayer - the current player

playerWinsRound

public void playerWinsRound()
Description copied from interface: UI
Update UI to indicate that player wins the round.

Specified by:
playerWinsRound in interface UI

dealerWinsRound

public void dealerWinsRound()
Description copied from interface: UI
Update UI to indicate that player wins the round

Specified by:
dealerWinsRound in interface UI

roundIsPush

public void roundIsPush()
Description copied from interface: UI
Update UI to indicate that the round is a push.

Specified by:
roundIsPush in interface UI

playerActionTaken

public void playerActionTaken(Player player,
                              Player.Action action)
Description copied from interface: UI
Update UI to indicate the action that was taken.

Specified by:
playerActionTaken in interface UI
Parameters:
player - the player
action - the action

endRound

public void endRound()
Description copied from interface: UI
Update UI to indicate that the hand has ended.

Specified by:
endRound in interface UI

quitMessage

public void quitMessage()
Description copied from interface: UI
Quit message.

Specified by:
quitMessage in interface UI

introMsg

public void introMsg()
Description copied from interface: UI
Intro msg.

Specified by:
introMsg in interface UI

exitMsg

public void exitMsg()
Description copied from interface: UI
Exit msg.

Specified by:
exitMsg in interface UI