Objectives

On completion of this assignment a student should be able to write simple Java application that:

  • Makes use of selection and repetition constructs to achieve desired outcomes
  • Stores data to and reads data from arrays
  • Generates output to and reads input from the console window
  • Reads data from and writes data to text file
  • Manipulates string using Java API "String" class
  • Handles basic exceptions
  • Applies object-oriented concepts where applicable

Scope

You are required to design, develop and test a one player Java game application named "Blackjack".

Besides providing the required functionalities, your program should incorporate appropriate error handling. Comments are also to be inserted to improve program clarity. Before you start coding your program, you are strongly advised to carry out proper problem analysis and program design.

You are required to use JDK 1.5 developer version or later.

Background

Blackjack is a card game which compares the values of cards hold by a player and the dealer.

In this game, the player and dealer attempts to accumulate cards of total values between 16 and 21. Total card values of below 16 and above 21 is consider as bust.

See image. figure1.png

Values of Cards

The game uses one or more decks of the standard poker cards. Suits (i.e. Heart, Diamond, Spade and Club) has no particular meaning in this game.

The cards are valued as follows:

  • An Ace can count as either 1 or 11, (see below for explanation).
  • Cards from 2 through 9 are valued at their face value.
  • The 10, Jack, Queen, and King are all valued at 10.

The value on a player hand is the sum of the point counts of each card in the hand. For example, a hand containing (4,6,9) has the value of 19.

The Ace can be counted as either 1 or 11. It is assumed that the value of Ace always has the valuethat makes the best hand.

For example, the player has the beginning hand (Ace, 7). The total value can be either 8 or 18. If the player stops there, it will be 18.

If the player draws another card, and it is a (3), the player will then have (Ace, 7, 3). The player total value is now 21, counting the Ace as 11.

However, if the player draw a third card which is 9. The hand is now (Ace, 7, 9) which totals to 17.

Notice that now the Ace must be counted as only 1 to avoid going over 21.

Game Procedure

The game starts with the dealer shuffles the deck of cards. Then the player place bet. After the bet is placed, the dealer will deal (distribute) the cards to the players. The dealer make two passes so that the players and the dealer have two cards each. (Two passes means that the dealer must distribute the cards in such a way that, the first card belongs to the player, the second card belongs to the dealer, the third card belongs to the player and the fourth card belows to the dealer.)

The first card of the dealer and player are both hidden (i.e. face down) for each other. The dealer and player can view their own hidden first card.

The other cards (second card and above) are visible to both the dealer and player.

Once the player has the first two cards, the player can choose to “Stand” or “Hit”. If the player choose to “Hit” , the dealer will deal one more card from the deck to the player.

The player can then continue to “Hit” or choose to “Stand”.

The player can Hit a maximum of four cards.

After the player “Stand”, the dealer can choose to “Hit” (maximum of four cards) or “Stand”.

Once the dealer “Stand”, both the dealer and player must reveal the hidden cards and compare their values on hand.

If the dealer wins, the dealer takes all the bet placed by the player. If the player wins, the dealer gives the same amount of bet placed to the player.

All thecards on the table are shuffled and placed at the end of the deck. The game will start again unless the player choose to leave the game.

Required Functionalities

Develop a Java program for the Blackjack game describled above. You also required to develope an “Intelligent” dealer that will decide if it should “Hit” or “Stand”. A very basic implementation of the “Intelligent” dealer is as follow:

  • If the total values is below 16, “Hit”.
  • If the total values is 16 or above, “Stand”.

There are two modules in this program; Administration and Game Play module

Administration Module

This module allows the administor to

  • Create a player
  • Delete a player
  • Issue more chips to a player
  • Reset player’s password
  • Change adminstrator’s password
  • Logout

Error Handling

Your program should be able to handle error situations like where a player enter wrong password or has insufficient chips. You should look out for other possible exceptions and handle them too.

Report

  • Classes design: Draw all the Class diagram (UML standards) with the class name, attributes and methods clearly stated.
  • Test-run of Program: You have to provide screen outputs (similar to those shown in Section 4)
  • to show the correct execution of your program according to the requirements stated.
  • Error Handling: List down the errors and exceptions that your program can handle. Provide screen captures here if necessary.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.