Create a Game class that contains the following members: - A private data member to store a player name - A private data

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Create a Game class that contains the following members: - A private data member to store a player name - A private data

Post by answerhappygod »

Create A Game Class That Contains The Following Members A Private Data Member To Store A Player Name A Private Data 1
Create A Game Class That Contains The Following Members A Private Data Member To Store A Player Name A Private Data 1 (181.64 KiB) Viewed 39 times
Create a Game class that contains the following members: - A private data member to store a player name - A private data member to store the number of games played - A private data member to store an integer pointer that will point to a dynamic array that will store games' scores - A private data member to store the highest score - A private non-inline member function that computes the highest score of all randomly generated scores. Please note that the definition of this function is placed outside the class, while its prototype is inside the class. - A public non-inline constructor function that obtains a player name and the number of games played from the user. This function also uses random numbers generator to generate scores randomly and store these random scores into the array that is the data member of the class. Random scores should be in the range from 0 to 100 . This function will call the function that computes the highest score as well. - A public member function that displays the player's name and his/her highest score. - A public destructor function to delete the dynamic array that stores scores. Design the main( ) function that prompts the user to choose a number of players. A dynamic array of Game objects will be created and the size of this array is equal to the number of players. The program will call class member functions, including constructor function that will be automatically called, to obtain the player name, generate scores randomly and compute and display the highest scores respectively. Please note that the error checking for a memory allocation error is required. A sample output of this program could be as follows: Number of players =>3 Enter player name #1 and number of games ⇒> Joe 5 Enter player name #2 and number of games ⇒ Mike 9 Enter player name #3 and number of games ⇒ Yo 7 Highest scores:  Joˊe =83 Mike =91 Yo =88​
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply