Question: How would you develop a blackjack game in c++ using clases and going through the following steps? Then change CardDeck to use dynamic memory allocation.

How would you develop a blackjack game in c++ using clases and going through the following steps? How would you develop a blackjack game in c++ using clases

Then change CardDeck to use dynamic memory allocation.and going through the following steps? Then change CardDeck to use dynamicmemory allocation. 1. Develop a C++ class named CardDeck that stores a

1. Develop a C++ class named CardDeck that stores a deck of cards as an array of n integers (to practice data hiding) and a corresponding "size" variable stored as a private data member in your new class. 2. The non-default constructor should receive a value n and then place the integers from 0 to n - 1 into the array. 3. Please specify a "fall back" value for this non-default constructor so n is assumed to be 52 (aka CardDeck(int = 52); as a prototype) 4. Write a public member function getSize() that returns the size of the current deck using the size variable explained above. 5. Provide a utility function named shuffle that performs a shuffle. You can either implement this yourself or use a temporary vector and the the random_shuffle algorithm of the STL (as covered in this week's challenge). Note that srand() must be called to change the random number seed for the shuffle. For now, we recommend you simply place this srand() call in the non-default constructor. Implement a simple BlackJack player using CardDeck as a foundation as follows: Aces are always 11 players have only two options (hit or stand) The computer dealer always stops when they reach 17 or higher. You will need to implement a Deal() public member function (or similar) to get cards from your deck for the game and additional functions as necessary). Keep track of how many times a player wins and the dealer wins in your game Ask the user if they want to continue playing after each game. Also, when there are fewer than 15 cards, open a "new" deck and shuffle it before continuing the game. 1. Develop a C++ class named CardDeck that stores a deck of cards as an array of n integers (to practice data hiding) and a corresponding "size" variable stored as a private data member in your new class. 2. The non-default constructor should receive a value n and then place the integers from 0 to n - 1 into the array. 3. Please specify a "fall back" value for this non-default constructor so n is assumed to be 52 (aka CardDeck(int = 52); as a prototype) 4. Write a public member function getSize() that returns the size of the current deck using the size variable explained above. 5. Provide a utility function named shuffle that performs a shuffle. You can either implement this yourself or use a temporary vector and the the random_shuffle algorithm of the STL (as covered in this week's challenge). Note that srand() must be called to change the random number seed for the shuffle. For now, we recommend you simply place this srand() call in the non-default constructor. Implement a simple BlackJack player using CardDeck as a foundation as follows: Aces are always 11 players have only two options (hit or stand) The computer dealer always stops when they reach 17 or higher. You will need to implement a Deal() public member function (or similar) to get cards from your deck for the game and additional functions as necessary). Keep track of how many times a player wins and the dealer wins in your game Ask the user if they want to continue playing after each game. Also, when there are fewer than 15 cards, open a "new" deck and shuffle it before continuing the game

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!