Introduction

You've just been hired by an internet gaming company to develop online games. Your first job is to create a prototype command line driven blackjack card game. The previous programmer learned just enough to cobble together a partial program design. You have been employed to finish the job.

The Game

Develop a simplified version of the card game Blackjack (otherwise known as “21”). In this game, the dealer deals two cards to himself and two cards to each player. One of the dealer’s cards is hidden. The hands should be displayed at the start of the game. Each player can then request more cards. one at a time until they pass. Play then goes on to the next player. The aim is to try to get as close to 21 as possible, but not going over 21. When all players have passed, the dealer has a turn. When the dealer has passed. the game ends. The winners are the players who got a higher score than the dealer without exceeding 21.

Programming Style

Here are the minimum style requirements. as laid out by your supervisor:

  • You must indent your code clearly. Every variable must have a comment stating what it is used for. Every method must have a comment describing its parameters and what the method does. For public methods, the comment must not reveal any implementation details. Every class must have a comment describing what it represents.
  • In all your code. every class and interface must start with a capital letter Every one of them. You will lose 1 mark for every non-capitalised class and interface. Example of a good class name: class Hello. Example of a bad class name: class hello.
  • In all your code, every item that is not a class (such as packages, methods, and parameters) must start with a lowercase letter. You will lose 1 mark for every capitalised non- class/interface. Example of a good variable name: int count. Example of a bad variable name: int Count.
  • In all your code. please capitalise every internal word. Examples: int aLongVariableName and class AlongClassName. I will be more flexible on this requirement, but please try to adhere to it.
  • Put each class in its own file.

Further Game Details

  • There is only one dealer.
  • Any number of players can play.
  • The game is only played once.
  • Cards are the numbers 1 through ll. and each card is equally likely.
  • There are no suits or picture cards (i.e. kings. queens, jacks).
  • Cards are randomly generated. not drawn from a deck of limited size.
  • If a player’s total is greater than 21 they “bust” and lose.
  • If a dealer busts. anyone who didn’t bust is a winner.
  • You should display the winner’s and their hands at the end of the game.
  • At the beginning of the game all hands should be shown as in the following example (note the X for the dealer’s hidden card): See image.

The Code

See code 1 of 2. See image.

See code 2 of 2. See image.

Things To Think About

  • Can you utilise the fact that a dealer is also a type of player? How would the design change?
  • Create some more types of players, for example:
    • RandomPlayer - who randomly determines whether another card should be taken
    • EvenPlayer - who doesn't like odd mmlbers so will ask for another a card if the total is odd
    • NoisyPlayer - who remarks whenever a card is dealt to them
    • Think of a few more! What uncles(mg players can you come up with?
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.