Blackjack

com.amoebacode.blackjack.core
Class Player

java.lang.Object
  |
  +--com.amoebacode.blackjack.core.GameObject
        |
        +--com.amoebacode.blackjack.core.Participant
              |
              +--com.amoebacode.blackjack.core.Player
All Implemented Interfaces:
IGameObject, IParticipant, IPlayer

class Player
extends Participant
implements IPlayer

Player manages the player's hands, initial bet, and net gain.

Version:
0.9
Author:
Jason Gurney

Field Summary
private  int initialBet
          The user's initial bet for the current round
private  double netGain
          The user's net gain for the current round
 
Fields inherited from class com.amoebacode.blackjack.core.Participant
hands
 
Fields inherited from class com.amoebacode.blackjack.core.GameObject
listeners, parent
 
Fields inherited from interface com.amoebacode.blackjack.core.IPlayer
MAXIMUM_NUMBER_OF_HANDS
 
Constructor Summary
protected Player(IRound round)
          Default protected constructor.
 
Method Summary
 boolean allHandsBustedOrSurrendered()
          Indicates whether all of the player hands have busted or surrendered.
 boolean allHandsFinished()
          Indicates whether all of the player hands have finished.
 void computeNetGain(int dealerScore)
          Computes the total net gain for all of the player hands, based on the specified dealer score and notifies the GUI listeners.
private  void createSplitHand(ICard splitCard)
          Creates a new hand based on the specified split card and notifies the GUI listeners.
private  IPlayerHand getFirstPlayer()
          Returns the player's first hand.
 double getNetGain()
          Returns the user's net gain for the current round.
private  PlayerEventListenerCollection getPlayerEventListenerCollection()
          Returns the event listener collection for this player.
private  IPlayerHand getPlayerHandAt(int index)
          Returns the specified user's hand.
 boolean hasMaximumNumberOfHands()
          Indicates whether the user is playing the maximum number of hands.
 void setInitialBet(int initialBet)
          Sets the initial bet for the current round.
 void setupFirstHand()
          Sets up the first hand for this participant (called at the beginning of the round) and notifies the GUI listeners.
 void split(IPlayerHand hand)
          Splits the specified hand into two hands (as long as the player has less than the maximum number of hands).
 void updateAvailableCommands()
          Updates the set of available player hand commands for each GUI listener.
 
Methods inherited from class com.amoebacode.blackjack.core.Participant
addHand, allHandsBlackjack, clear, getFirstHand, getHandAt, getNumberOfHands, getRound
 
Methods inherited from class com.amoebacode.blackjack.core.GameObject
addEventListener, getEventListenerCollection, getGame, getParent, hasParent, setEventListenerCollection
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 
Methods inherited from interface com.amoebacode.blackjack.core.IParticipant
allHandsBlackjack, clear, getFirstHand, getNumberOfHands
 
Methods inherited from interface com.amoebacode.blackjack.core.IGameObject
addEventListener, getGame, getParent
 

Field Detail

initialBet

private int initialBet
The user's initial bet for the current round

netGain

private double netGain
The user's net gain for the current round
Constructor Detail

Player

protected Player(IRound round)
Default protected constructor.
Parameters:
round - the current IRound
Method Detail

getPlayerEventListenerCollection

private PlayerEventListenerCollection getPlayerEventListenerCollection()
Returns the event listener collection for this player.
Returns:
this object's PlayerEventListenerCollection

setInitialBet

public void setInitialBet(int initialBet)
Description copied from interface: IPlayer
Sets the initial bet for the current round.
Specified by:
setInitialBet in interface IPlayer
See Also:
IPlayer.setInitialBet(int)

setupFirstHand

public void setupFirstHand()
Description copied from interface: IParticipant
Sets up the first hand for this participant (called at the beginning of the round) and notifies the GUI listeners.
Specified by:
setupFirstHand in interface IParticipant
See Also:
IParticipant.setupFirstHand()

hasMaximumNumberOfHands

public boolean hasMaximumNumberOfHands()
Description copied from interface: IPlayer
Indicates whether the user is playing the maximum number of hands.
Specified by:
hasMaximumNumberOfHands in interface IPlayer
See Also:
IPlayer.hasMaximumNumberOfHands()

getFirstPlayer

private IPlayerHand getFirstPlayer()
Returns the player's first hand.
Returns:
the first IPlayerHand

getPlayerHandAt

private IPlayerHand getPlayerHandAt(int index)
Returns the specified user's hand.
Parameters:
index - the index of the specified hand
Returns:
the specified IPlayerHand

split

public void split(IPlayerHand hand)
Description copied from interface: IPlayer
Splits the specified hand into two hands (as long as the player has less than the maximum number of hands).
Specified by:
split in interface IPlayer
See Also:
IPlayer.split(IPlayerHand)

createSplitHand

private void createSplitHand(ICard splitCard)
Creates a new hand based on the specified split card and notifies the GUI listeners.
Parameters:
splitCard - the ICard split from an existing hand

allHandsFinished

public boolean allHandsFinished()
Description copied from interface: IPlayer
Indicates whether all of the player hands have finished.
Specified by:
allHandsFinished in interface IPlayer
See Also:
IPlayer.allHandsFinished()

allHandsBustedOrSurrendered

public boolean allHandsBustedOrSurrendered()
Description copied from interface: IPlayer
Indicates whether all of the player hands have busted or surrendered. (This means that the dealer does not need to take any cards.)
Specified by:
allHandsBustedOrSurrendered in interface IPlayer
See Also:
IPlayer.allHandsBustedOrSurrendered()

computeNetGain

public void computeNetGain(int dealerScore)
Description copied from interface: IPlayer
Computes the total net gain for all of the player hands, based on the specified dealer score and notifies the GUI listeners.
Specified by:
computeNetGain in interface IPlayer
See Also:
IPlayer.computeNetGain(int)

getNetGain

public double getNetGain()
Description copied from interface: IPlayer
Returns the user's net gain for the current round.
Specified by:
getNetGain in interface IPlayer
See Also:
IPlayer.getNetGain()

updateAvailableCommands

public void updateAvailableCommands()
Description copied from interface: IPlayer
Updates the set of available player hand commands for each GUI listener.
Specified by:
updateAvailableCommands in interface IPlayer
See Also:
IPlayer.updateAvailableCommands()

Blackjack

Copyright © 2002 amoebacode.com.