You are required to write a basic game representing a simplified version of the game Black Jack.
In this simplified version the casino will only use a single deck of cards and the deck will be reset after each hand.
As a way to relax in your free time, you and your class mate have decided to go to a local casino to play some Black Jack. Before commencing the game, you are required to register your names at the casino, at which point you and your friend will be given an allowance to spend at the tables in the casino. As space is limited in this casino, there are only two playing tables available. To sit at any given table both players must at least have an allowance greater or equal to the minimum bet specified by that table.
Once seated at a table, each player can chose to participate in a hand (betting) or chose to spectate. Both players will remain at the table, until either one player has less than the minimum bet or you decide to leave the table at the end of a hand. Due to your close friendship, both players must remain together at all times.
At the start of a hand, each player has the choice of whether they wish to bet and the amount to bet. This bet must be equal to or above the minimum bet specified by the table. For our needs your maximum bet is only limited by your allowance (this is a rich casino). The dealer will then deal a single card face up to each player that has placed a bet (including themself). The second card won’t be given to a player until it is their turn to act (this reduces the amount of information available on the table).
Each active player has the option to act. Their aim is to get to 21 without going over. They can chose to either hit (receive another card) or sit (not receive any more cards). In our version of the game, the player can only receive a maximum of 5 cards at which point they must sit. If a player goes over 21, they are bust and automatically lose the hand. There is no need to handle splitting (see YouTube video or Wikipedia) in this assignment.
Note: All values of 21 will be considered equal, no matter what cards are used.
After each player has acted, the dealer must keep hitting until they are greater than or equal to 17, at which point they must sit. The dealer’s hand is then compared to each active player (a show down). The rules behind a show down are determined in the following order.
1) If a player has busted they automatically lose their bet.
2) If the dealer has busted the player automatically wins double their bet.
3) If the dealer has a stronger hand the player loses their bet.
4) If the dealer has a hand equal to the player, it is a draw (push) and the player gets their bet back.
5) If the player has the stronger hand they have won and they get double their bet back.
Note: To determine the strength (total value) of a hand the following rules apply: cards 10, Jack, Queen, and King all have the value 10 and can be considered equivalent in comparing hands. Any Ace will be treated as 11 if the hand strength adds to 21, otherwise they will be given a value of 1. All other cards have theur expected values.
Your program should consist of the following classes:
1) Card class, which represents a single card in a deck of cards. The card class you wrote in Prac7 should contain most of the desired functionality.
2) Player class, which manages the players in the game. It stores the players’ full name, their current allowance and their current bet value. Additionally it will store an array of cards which will have an upper limit of 5. The default allowance for a player is $100.00. The player class you wrote in Prac 8 should provide you with a supportable base to get you started.
3) Deck class, used to represent a single deck of cards. The deck class you wrote in Prac 10 should contain most of the desired functionality.
4) Table class, used to represent a single table at our casino. It stores the table name (eg: “High rollers table”), the minimum bet, the dealer (which is represented as a player that doesn’t bet) and the current players at the table as an array. Only two players can sit at any given table. The table should also keep track if a hand is currently in progress.
5) Casino class, which is the main game logic. This casino has only one deck of cards and players can only play at one table at a time.
We have provided sample documentation to assist you in writing these classes. However, you are welcome to design and implement your methods different to the provided documentation.
This structure allows you to write some basic multi-purpose classes (Player, Deck, and Card) that could be used for other games without the need to change them (keep that in mind).
Part 1: Class Diagram
As a first task it is important to understand and document the program design. Read the whole assignment specification and draw a class diagram to represent the program design. Include all five classes, attributes, and methods required.
Part 2: Card Class
1) Implement the Card class, including the relevant attributes, accessors, mutators, toString and constructor. The constructor should receive two parameters including the suit and value, these values should be validated.
2) Write a test driver to test that a Card object can be successfully created and functions correctly.
Part 3: Player Class
1) Implement the Player class, including the relevant attributes, accessors, mutators, methods and constructor. Its constructor should be designed such that it accepts a player name and allowance given to the player (this is to make the game more flexible). Both these values should be validated and if invalid should be given sensible default values. These default values should be defined as constants.
2) Use the test driver you wrote in Prac 8 to test the functionality of this class.
Part 4: Deck Class
1) Implement the Deck class, including the relevant attributes, accessors, mutators, methods and constructor. The constructor automatically populates its card array with unique Card objects. Other functionality should include having a method that always returns a unique card and removes it from the deck. Once the deck is empty it should return null.
2) Use the test driver you wrote in Prac 10 to test the functionality of this class.
Part 5: Table Class
1) Implement the Table class, including the relevant attributes, accessors, mutators, methods and constructor. Its constructor should be designed such that it accepts a table name and the minimum bet allowed at that table. Both these values should be validated and if invalid should be given sensible default values. These default values should be defined as constants.
2) Write a test driver to test that a Table object can be successfully created and functions correctly. Ensure that you test the validation of each method (including the constructor) and that the toString() returns the correct String.
Part 6: Casino Class
Write a main program class called Casino to allow a user to play the game. Your game will need to emulate the functionality described in the game and hand overview above.
Refer to the provided sample output text file as a walkthrough of how the game should function. This output is provided as an example only; your program’s output does not need to match the sample.
Number of downloads: 293