blackjack
Class Blackjack

java.lang.Object
  extended by blackjack.Blackjack
All Implemented Interfaces:
BlackjackEngine

public class Blackjack
extends java.lang.Object
implements BlackjackEngine


Field Summary
 
Fields inherited from interface blackjackGUILibrary.BlackjackEngine
BLACKJACK, BUST, DEALER_WON, DRAW, GAME_IN_PROGRESS, HAS_21, LESS_THAN_21, PLAYER_WON
 
Constructor Summary
Blackjack(java.util.Random randomGenerator, int numberOfDecks)
           
 
Method Summary
 void createAndShuffleGameDeck()
          Creates and shuffles the card deck using a random number generator.
 void deal()
          Creates and shuffles the deck.
 double getAccountAmount()
          Returns the player's account amount
 double getBetAmount()
          Returns a double representing the bet amount.
 Card[] getDealerCards()
          Returns dealer's cards.
 int getDealerCardsEvaluation()
          Returns an integer value that can assume the values LESS_THAN_21 if the dealers's cards have a value less than 21, BUST if the dealers's cards have a value greater than 21, and BLACKJACK if the dealer has an Ace along with a Jack, Queen, or King.
 int[] getDealerCardsTotal()
          Returns an array representing the possible value(s) associated with the dealers's cards if the card's represent a value less than or equal to 21.
 Card[] getGameDeck()
          Returns the current deck of cards .
 int getGameStatus()
          Returns an integer representing the game status.
 int getNumberOfDecks()
          Returns the number of decks being used.
 Card[] getPlayerCards()
          Returns player's cards.
 int getPlayerCardsEvaluation()
          Returns an integer value that can assume the values LESS_THAN_21 if the player's cards have a value less than 21, BUST if the player's cards have a value greater than 21, and BLACKJACK if the player has an Ace along with a Jack, Queen, or King.
 int[] getPlayerCardsTotal()
          Returns an array representing the possible value(s) associated with the player's cards if the card's represent a value less than or equal to 21.
 void playerHit()
          Retrieves cards from the deck and assigns the card to player.
 void playerStand()
          Flips the dealer's card that is currently face down and assigns cards to the dealer as long as the dealer doesn't bust and the cards' have a value less than 16.
 void setAccountAmount(double amount)
          Updates the player's account with the parameter value.
 boolean setBetAmount(double amount)
          Updates the bet amount to the provided value if the bet amount does not exceeds the current account amount.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Blackjack

public Blackjack(java.util.Random randomGenerator,
                 int numberOfDecks)
Method Detail

getNumberOfDecks

public int getNumberOfDecks()
Description copied from interface: BlackjackEngine
Returns the number of decks being used.

Specified by:
getNumberOfDecks in interface BlackjackEngine
Returns:
number of decks

createAndShuffleGameDeck

public void createAndShuffleGameDeck()
Description copied from interface: BlackjackEngine
Creates and shuffles the card deck using a random number generator. When creating the deck of cards load the suits in the following order: SPADES, DIAMONDS, HEARTS and CLUBS. At the same time, each suit should be loading starting with the ACE, followed by cards with a face value of "2" through "10", followed by the "JACK", "QUEEN", and "KING".

Specified by:
createAndShuffleGameDeck in interface BlackjackEngine

getGameDeck

public Card[] getGameDeck()
Description copied from interface: BlackjackEngine
Returns the current deck of cards .

Specified by:
getGameDeck in interface BlackjackEngine
Returns:
Card array representing deck of cards.

deal

public void deal()
Description copied from interface: BlackjackEngine
Creates and shuffles the deck. It then retrieves cards from the deck and assigns cards to the dealer and player. A total of four cards are dealt where the player receives the first card. The first card the dealer receives must be face down. Once the cards have been dealt the game's status will be GAME_IN_PROGRESS.

Specified by:
deal in interface BlackjackEngine
See Also:
createAndShuffleGameDeck

getDealerCards

public Card[] getDealerCards()
Description copied from interface: BlackjackEngine
Returns dealer's cards.

Specified by:
getDealerCards in interface BlackjackEngine
Returns:
Card array representing the dealer's cards.

getDealerCardsTotal

public int[] getDealerCardsTotal()
Description copied from interface: BlackjackEngine
Returns an array representing the possible value(s) associated with the dealers's cards if the card's represent a value less than or equal to 21.

Specified by:
getDealerCardsTotal in interface BlackjackEngine
Returns:
Integer array representing the possible value(s) or null if cards represent a value higher than 21.

getDealerCardsEvaluation

public int getDealerCardsEvaluation()
Description copied from interface: BlackjackEngine
Returns an integer value that can assume the values LESS_THAN_21 if the dealers's cards have a value less than 21, BUST if the dealers's cards have a value greater than 21, and BLACKJACK if the dealer has an Ace along with a Jack, Queen, or King. If the dealers's cards have a value equivalent to 21 and the hand does not correspond to a blackjack, HAS_21 will be returned.

Specified by:
getDealerCardsEvaluation in interface BlackjackEngine
Returns:
Integer value that corresponds to one of the following: LESS_THAN_21, BUST, BLACKJACK, HAS_21

getPlayerCards

public Card[] getPlayerCards()
Description copied from interface: BlackjackEngine
Returns player's cards.

Specified by:
getPlayerCards in interface BlackjackEngine
Returns:
Card array representing the player's cards.

getPlayerCardsTotal

public int[] getPlayerCardsTotal()
Description copied from interface: BlackjackEngine
Returns an array representing the possible value(s) associated with the player's cards if the card's represent a value less than or equal to 21.

Specified by:
getPlayerCardsTotal in interface BlackjackEngine
Returns:
Integer array representing the possible value(s) or null if cards represent a value higher than 21.

getPlayerCardsEvaluation

public int getPlayerCardsEvaluation()
Description copied from interface: BlackjackEngine
Returns an integer value that can assume the values LESS_THAN_21 if the player's cards have a value less than 21, BUST if the player's cards have a value greater than 21, and BLACKJACK if the player has an Ace along with a Jack, Queen, or King. If the player's cards have a value equivalent to 21 and the hand does not correspond to a blackjack, HAS_21 will be returned.

Specified by:
getPlayerCardsEvaluation in interface BlackjackEngine
Returns:
Integer value that corresponds to one of the following: LESS_THAN_21, BUST, BLACKJACK, HAS_21

playerHit

public void playerHit()
Description copied from interface: BlackjackEngine
Retrieves cards from the deck and assigns the card to player. The new sets of cards will be evaluated. If the player busts the game is over and the games's status will be updated to DEALER_WON. Otherwise the game's status is GAME_IN_PROGRESS.

Specified by:
playerHit in interface BlackjackEngine

playerStand

public void playerStand()
Description copied from interface: BlackjackEngine
Flips the dealer's card that is currently face down and assigns cards to the dealer as long as the dealer doesn't bust and the cards' have a value less than 16. Once the dealer has a hand with a value greater than or equal to 16, and less than or equal to 21, the hand will be compared against the player's hand and whoever has the hand with a highest value will win the game. If both have the same value we have a draw. The game's status will be updated to one of the following values: DEALER_WON, PLAYER_WON, or DRAW. The player's account will be updated with a value corresponding to twice the bet amount if the player wins. If there is a draw the player's account will be updated with the only the bet amount.

Specified by:
playerStand in interface BlackjackEngine

getGameStatus

public int getGameStatus()
Description copied from interface: BlackjackEngine
Returns an integer representing the game status.

Specified by:
getGameStatus in interface BlackjackEngine
Returns:
DRAW, PLAYER_WON, DEALER_WON OR GAME_IN_PROGRESS

setBetAmount

public boolean setBetAmount(double amount)
Description copied from interface: BlackjackEngine
Updates the bet amount to the provided value if the bet amount does not exceeds the current account amount.

Specified by:
setBetAmount in interface BlackjackEngine
Returns:
true if the bet has been set and false otherwise.

getBetAmount

public double getBetAmount()
Description copied from interface: BlackjackEngine
Returns a double representing the bet amount.

Specified by:
getBetAmount in interface BlackjackEngine
Returns:
bet amount.

setAccountAmount

public void setAccountAmount(double amount)
Description copied from interface: BlackjackEngine
Updates the player's account with the parameter value.

Specified by:
setAccountAmount in interface BlackjackEngine

getAccountAmount

public double getAccountAmount()
Description copied from interface: BlackjackEngine
Returns the player's account amount

Specified by:
getAccountAmount in interface BlackjackEngine
Returns: