P: 8 | I've found some programs of how to create a standard game of blackjack on C++. But how would you do it using structs? Here is my assignment: Problem Statement: The purpose of this project is to create a game of Blackjack, which can be played by one player against the dealer (represented by the computer). The deck of cards is to be stored as an array of Card structures. Blackjack is played with a deck of 52 cards, consisting of four suits (hearts, clubs, diamonds, spades), each with 13 face values (Ace, King, Queen, Jack, 10, 9, ... 2). King, Queen, Jack and 10 all have a point count of 10; the Ace may be counted as either 1 or 11 whichever gives the higher count without going over 21; the remaining cards have their face values as their point count. The objective of the game for the player is to hold a higher point count than the dealer without going over 21. Ties go to the dealer. Playing the game proceeds as follows 1. Dealer shuffles the cards and lays them face down (that means neither the player nor the dealer can see them until cards are dealt). Cards are dealt off the top of this deck. 2. One card is dealt face down to the dealer and one to the player. The player is allowed to see the card dealt to him/her, but cannot see the card dealt to the dealer. 3. One card is dealt face up to the dealer and to the player. The player can see both these cards. 4. On each successive round, both the player and the dealer may request one more card face up. Once the player or dealer declines a card, that person cannot receive any more cards. When both the player and the dealer decide to stop, or one of them goes over 21, cards are turned up and the winner is determined as follows. The point count used for each is the highest possible without going over 21 – with an Ace counting 11 or with an Ace counting 1. In case the player goes over 21 the dealer wins. In case the dealer goes over 21 and the player does not, the player wins. If neither goes over 21, the winner is determined by the highest point count, with ties going to the dealer. 5. To keep it simple - here is how the dealer figures out when to stop asking for cards. The dealer must continue to request cards until his total is 17 or greater. An Ace in the dealer's hand is always counted as 11 if possible without the dealer going over 21 How to play the game with a computer Design and implement a program to simulate the game of Blackjack as described above. Make the human-computer interface as clear and user-friendly as possible. Cards shown should be the ones the player can see. Show the cards in the form, for example, “Ace of Diamonds”, “Three of Hearts”, etc. The player (user of the program) inputs choices for the player. The dealer choices must be played your program. Requirements: Representing the card deck: The deck of cards should be stored as an array of Card structures, where each struct has three members – one string giving the suit, one string giving the card name, one integer giving the face value. So, for example, the three of Diamonds will be represented as suit as string “Diamonds” name as string “three” value as int 3 And the Jack of Spades will be represented as suit as string “Spades” name as string “Jack” value as int 11 Initialize the card deck array with the correct values. The first card should be an “Ace” of “Diamonds” with a value of 1, the second card should be a “Two” of “Diamonds” with a value of 2, etc. Write at least 5 functions Write a function to shuffle the cards. . Here’s how to shuffle the cards: Pick 2 random numbers between 0 and 51 and exchange these cards in the deck – do this at least 25 times to get the card deck well shuffled. When the game starts, the dealer/computer shuffles the cards (by calling the shuffle function) and then deals two cards to the player and two to the computer/dealer. Use two more arrays of card structures to hold the player’s cards and the dealer’s cards. Write a second function to get a total count of the cards in a hand, Now the game continues until either the computer/dealer or the player decides to stop or either’s total point count goes over 21. Write a third function to get input from you, the player. Remember to let the player see all of their own cards as well as the top card held by the dealer. The player can decide to ask for another card, or to stop asking for cards, or to stop the game. Write a fourth function to act as the computer/dealer playing the game. A dealer can only see their own cards. When it is the dealer’s turn, they can get another card or stop asking for cards (see the strategy described in 5 above.) When the game is over (either has a total of over 21 or the player has requested that the game stops), the winner must be determined. Write a fifth function to determine and announce the winner. Organize the program so that the main program calls functions to do the work. Be sure to provide comments describing what each function does as well as describing what each segment of your program is doing. Your program should be organized using separate files: 1 The .h file 2 The .cpp file containing the main program 3 One or more .cpp file(s) containing the functions Submission: Zip all files and upload the zipped file. |