Question
Using C++, write an application that will allow 100 Players to play a game of rolling dice where each player will roll 20 dice. The
Using C++, write an application that will allow 100 Players to play a game of rolling dice where each player will roll 20 dice. The application should have two classes: - A class name Die will simulate a single die. Die will have two functions. The roll function should use a random object to generate and return a random number between 1 and 6. The getValue function should return the value from the most recent roll.
- A class named Player that will have three pieces of field data: an array of 20 dice, an integer playerNumber that will hold the integer value that identifies the player (player1, player2 player100) and an variable sumOfDice that will hold the sum of all 20 dice rolled. Player will have 6 functions: The play function should roll each dice in the dice array and set the sumOfDice with the sum of all the dice rolled. The getNumberOfDice fuction should return the number of dice the player has (this should update itself if the number of dice in the array is changed). The getPlayerNumber fuction should return the number assigned to the player. The getSingleDieValue fuction should return the value of a single dice of the dice array when passed in the data of which die is requested. The getSumOfDice function should return the sum of all of the dice in the dice array. The setPlayerNumber should set the players number.
- In main, create an array of 100 Player objects and three functions. A function that is passed the array of 100 Players and returns nothing. The function will loop through the array setting the playerNumber for each player 0 - 99. A function that is passed the array of 100 Players and returns a Player pointer. The function will find the Player with the highest total value of all the dice rolled and return a pointer to that Player. A function that is passed a pointer to a Player object and returns nothing. The function will use the Player pointer to display all of the contents of the Player field data and stated that the player had the highest total of combined dice rolled. A function that tests the output of each Player's total dice rolls. It will display the sum of each player's dice roll in rolls of 5.
The application should use the standard form of the C++ header files with the class definitions will be in the .h files and the implementation of the functions in the .cpp files.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started