blackjackanalyst.observer
Class ConsolePlayerObserver

java.lang.Object
  extended by blackjackanalyst.observer.ConsolePlayerObserver
All Implemented Interfaces:
PlayerObserver

public class ConsolePlayerObserver
extends java.lang.Object
implements PlayerObserver

An implementation of interface PlayerObserver that writes to the console.

Author:
Michael Parker

Constructor Summary
ConsolePlayerObserver(Player _p)
          Creates a new player observer that writes to the console.
 
Method Summary
 Player getPlayer()
          Returns the player this object observes.
 void playerBets(int bet_amount, int bankroll)
          This method is invoked when the player makes a bet.
 void playerBlackjack(PlayerHand player_hand, int amount_won, int new_bankroll)
          This method is invoked when the observed player gets a blackjack.
 void playerBusts(PlayerHand player_hand, int amount_lost, int new_bankroll)
          This method is invoked when the player busts.
 void playerDealt(PlayerHand player_hand)
          This method is invoked when the player is dealt a new hand.
 void playerDoublesDown(Card dealt_card, PlayerHand new_hand)
          This method is invoked when the player doubles down and is drawn a final card.
 void playerDraws(Card dealt_card, PlayerHand new_hand)
          This method is invoked when the player hits and is drawn a new card.
 void playerInsures(int bet_amount, int bankroll)
          This method is invoked when the player makes his insurance bet.
 void playerJoins(Table t)
          This method is invoked when the player joins a table.
 void playerLeaves(Table t)
          This method is invoked when the player leaves the table it had previously joined.
 void playerLoses(PlayerHand player_hand, int amount_lost, int new_bankroll)
          This method is invoked when the observed player loses.
 void playerLosesInsurance(int amount_lost, int new_bankroll)
          This method is invoked when the observed player loses his insurance bet.
 void playerPush(PlayerHand player_hand, int held_bankroll)
          This method is invoked when the observed player ties the dealer, or pushes.
 void playerSplits(PlayerHand player_hand)
          This method is invoked when the player splits the hand.
 void playerStands(PlayerHand player_hand)
          This method is invoked when the player stands.
 void playerWins(PlayerHand player_hand, int amount_won, int new_bankroll)
          This method is invoked when the observed player wins, but does not get blackjack.
 void playerWinsInsurance(int amount_won, int new_bankroll)
          This method is invoked when the observed player wins his insurance bet.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConsolePlayerObserver

public ConsolePlayerObserver(Player _p)
Creates a new player observer that writes to the console.

Parameters:
_p - the player to observe
Method Detail

getPlayer

public Player getPlayer()
Returns the player this object observes.

Returns:
the observed player

playerJoins

public void playerJoins(Table t)
Description copied from interface: PlayerObserver
This method is invoked when the player joins a table.

Specified by:
playerJoins in interface PlayerObserver
Parameters:
t - the table the player has joined

playerLeaves

public void playerLeaves(Table t)
Description copied from interface: PlayerObserver
This method is invoked when the player leaves the table it had previously joined.

Specified by:
playerLeaves in interface PlayerObserver
Parameters:
t - the table the player has left

playerBets

public void playerBets(int bet_amount,
                       int bankroll)
Description copied from interface: PlayerObserver
This method is invoked when the player makes a bet.

Specified by:
playerBets in interface PlayerObserver
Parameters:
bet_amount - the amount the player bet
bankroll - the bankroll of the player, which includes the amount bet

playerInsures

public void playerInsures(int bet_amount,
                          int bankroll)
Description copied from interface: PlayerObserver
This method is invoked when the player makes his insurance bet.

Specified by:
playerInsures in interface PlayerObserver
Parameters:
bet_amount - the amount the player insures
bankroll - the bankroll of the player, which includes the amount bet

playerDealt

public void playerDealt(PlayerHand player_hand)
Description copied from interface: PlayerObserver
This method is invoked when the player is dealt a new hand.

Specified by:
playerDealt in interface PlayerObserver
Parameters:
player_hand - the hand dealt to the player

playerDraws

public void playerDraws(Card dealt_card,
                        PlayerHand new_hand)
Description copied from interface: PlayerObserver
This method is invoked when the player hits and is drawn a new card.

Specified by:
playerDraws in interface PlayerObserver
Parameters:
dealt_card - the new card the player draws
new_hand - the player hand including the drawn card

playerStands

public void playerStands(PlayerHand player_hand)
Description copied from interface: PlayerObserver
This method is invoked when the player stands.

Specified by:
playerStands in interface PlayerObserver
Parameters:
player_hand - the player hand stood with

playerBusts

public void playerBusts(PlayerHand player_hand,
                        int amount_lost,
                        int new_bankroll)
Description copied from interface: PlayerObserver
This method is invoked when the player busts.

Specified by:
playerBusts in interface PlayerObserver
Parameters:
player_hand - the player hand busted with
amount_lost - the amount the player lost
new_bankroll - the new bankroll of the player, after subtracting the loss

playerSplits

public void playerSplits(PlayerHand player_hand)
Description copied from interface: PlayerObserver
This method is invoked when the player splits the hand.

Specified by:
playerSplits in interface PlayerObserver
Parameters:
player_hand - the player hand that was split

playerDoublesDown

public void playerDoublesDown(Card dealt_card,
                              PlayerHand new_hand)
Description copied from interface: PlayerObserver
This method is invoked when the player doubles down and is drawn a final card.

Specified by:
playerDoublesDown in interface PlayerObserver
Parameters:
dealt_card - the final card the player draws
new_hand - the player hand including the drawn card

playerWins

public void playerWins(PlayerHand player_hand,
                       int amount_won,
                       int new_bankroll)
Description copied from interface: PlayerObserver
This method is invoked when the observed player wins, but does not get blackjack.

Specified by:
playerWins in interface PlayerObserver
Parameters:
player_hand - the hand the player won on
amount_won - the amount the player won
new_bankroll - the new bankroll of the player, after adding the winning

playerLoses

public void playerLoses(PlayerHand player_hand,
                        int amount_lost,
                        int new_bankroll)
Description copied from interface: PlayerObserver
This method is invoked when the observed player loses.

Specified by:
playerLoses in interface PlayerObserver
Parameters:
player_hand - the hand the player lost on
amount_lost - the amount the player lost
new_bankroll - the new bankroll of the player, after subtracting the loss

playerBlackjack

public void playerBlackjack(PlayerHand player_hand,
                            int amount_won,
                            int new_bankroll)
Description copied from interface: PlayerObserver
This method is invoked when the observed player gets a blackjack.

Specified by:
playerBlackjack in interface PlayerObserver
Parameters:
player_hand - the hand the player received blackjack on
amount_won - the amount the player won on blackjack
new_bankroll - the new bankroll of the player, after adding the winning

playerPush

public void playerPush(PlayerHand player_hand,
                       int held_bankroll)
Description copied from interface: PlayerObserver
This method is invoked when the observed player ties the dealer, or pushes.

Specified by:
playerPush in interface PlayerObserver
Parameters:
player_hand - the hand the player pushed on
held_bankroll - the unchanged bankroll of the player

playerWinsInsurance

public void playerWinsInsurance(int amount_won,
                                int new_bankroll)
Description copied from interface: PlayerObserver
This method is invoked when the observed player wins his insurance bet.

Specified by:
playerWinsInsurance in interface PlayerObserver
Parameters:
amount_won - the amount the player won
new_bankroll - the new bankroll of the player, after adding the winning

playerLosesInsurance

public void playerLosesInsurance(int amount_lost,
                                 int new_bankroll)
Description copied from interface: PlayerObserver
This method is invoked when the observed player loses his insurance bet.

Specified by:
playerLosesInsurance in interface PlayerObserver
Parameters:
amount_lost - the amount the player lost
new_bankroll - the new bankroll of the player, after subtracting the loss