blackjackanalyst
Class Table

java.lang.Object
  extended by blackjackanalyst.Table

public class Table
extends java.lang.Object

A blackjack table.

Author:
Michael Parker

Constructor Summary
Table(int _max_players, DealerStrategy _dealer_strat, int _min_bet, int _max_bet)
          Creates a new unnamed table with the given maximum number of players, dealer strategy, and minimum bet and maximum bet.
Table(java.lang.String _name, int _max_players, DealerStrategy _dealer_strat, int _min_bet, int _max_bet)
          Creates a new table with the given name, maximum number of players, dealer strategy, and minimum bet and maximum bet.
 
Method Summary
 boolean addPlayer(Player p)
          Attempts to add the given player to the table.
 int getMaximumBet()
          Returns the maximum bet at the table.
 int getMaxPlayers()
          Returns the maximum number of players at this blackjack table.
 int getMinimumBet()
          Returns the minimum bet at the table.
 java.lang.String getName()
          Returns the name of the table.
 int getNumPlayers()
          Returns the number of players at this blackjack table.
 ObserverList<TableObserver> getObservers()
          Returns the list of observers, to which observers for this table can be added, removed, and so forth.
 java.util.List<Player> getPlayers()
          Returns a list containing all the players at the blackjack table.
 DealerStrategy getStrategy()
          Returns the strategy used by the dealer.
 boolean hasRoom()
          Returns whether there is room for more players at the blackjack table.
 void playRound()
          Plays a single round of blackjack.
 void playRounds(int num_rounds)
          Plays the given number of rounds of blackjack.
 boolean removePlayer(Player p)
          Attempts to remove the given player from the table.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Table

public Table(int _max_players,
             DealerStrategy _dealer_strat,
             int _min_bet,
             int _max_bet)
Creates a new unnamed table with the given maximum number of players, dealer strategy, and minimum bet and maximum bet.

Parameters:
_max_players - the maximum number of blackjack players
_dealer_strat - the strategy used by the dealer
_min_bet - the minimum bet at this table
_max_bet - the maximum bet at this table

Table

public Table(java.lang.String _name,
             int _max_players,
             DealerStrategy _dealer_strat,
             int _min_bet,
             int _max_bet)
Creates a new table with the given name, maximum number of players, dealer strategy, and minimum bet and maximum bet.

Parameters:
_name - the name of the blackjack table
_max_players - the maximum number of blackjack players
_dealer_strat - the strategy used by the dealer
_min_bet - the minimum bet at this table
_max_bet - the maximum bet at this table
Method Detail

getName

public java.lang.String getName()
Returns the name of the table.

Returns:
the player name

getMaxPlayers

public int getMaxPlayers()
Returns the maximum number of players at this blackjack table.

Returns:
the maximum number of blackjack players

getStrategy

public DealerStrategy getStrategy()
Returns the strategy used by the dealer.

Returns:
the dealer strategy

getMinimumBet

public int getMinimumBet()
Returns the minimum bet at the table.

Returns:
the minimum bet

getMaximumBet

public int getMaximumBet()
Returns the maximum bet at the table.

Returns:
the maximum bet

getNumPlayers

public int getNumPlayers()
Returns the number of players at this blackjack table.

Returns:
the current number of blackjack players

hasRoom

public boolean hasRoom()
Returns whether there is room for more players at the blackjack table. This method returns true if and only if the current number of blackjack players is less than the maximum number permitted.

Returns:
true if more players can be added to the table, false otherwise

getPlayers

public java.util.List<Player> getPlayers()
Returns a list containing all the players at the blackjack table. The returned list is always backed by the players currently at the table; the returned list may not be modified, however, so that players cannot be added to or removed from the table through the list.

Returns:
the players currently at this table

addPlayer

public boolean addPlayer(Player p)
Attempts to add the given player to the table. For this method to succeed and return true, the table must have room for the player and the player must not be at a table already. Otherwise, this method returns false.

Parameters:
p - the player to add to the table
Returns:
true if the player is added to the table, false otherwise

removePlayer

public boolean removePlayer(Player p)
Attempts to remove the given player from the table. For this method to succeed and return true, the player must be at the table already.

Parameters:
p - the player to remove from the table
Returns:
true if the player is removed from the table, false otherwise

playRound

public void playRound()
Plays a single round of blackjack.


playRounds

public void playRounds(int num_rounds)
Plays the given number of rounds of blackjack.

Parameters:
num_rounds - the number of blackjack rounds to play

getObservers

public ObserverList<TableObserver> getObservers()
Returns the list of observers, to which observers for this table can be added, removed, and so forth.

Returns:
the list of observers for this table