Question
C++ You will design a program to play a simplified version of war, using dice instead of cards. There will be only one user, but
C++
You will design a program to play a simplified version of war, using dice instead of cards. There will be only one user, but 2 players for the game. The user will indicate the number of rounds to play. The user will also specify for each player the number of sides on the dice used and if that player is using regular or loaded dice. For example, one player could have a loaded 10-sided die while the other has a 4-sided die. User should be able to determine how "loaded" the die is - 2/3/4 etc times mores likely to return a high number.
To play the game, for each round, you roll a die of the appropriate type for each player. The higher result wins. If the results are equal, it is a draw. The winner of the game is the player who won the most rounds. Your program will print out which player won to the user.
Die class: requires an input integer N which determines the number of sides on the individual die. It includes a method to return a random integer between 1 and N as the result of rolling the die for once.
LoadedDie class: it inherits the behavior and elements of Die, but the number it returns is biased such that the average output of rolling it for several times will be higher than for a Die object. You can determine how you want to realize the biased function.
Game class: it will implement the simple dice-rolling game. In the menu function, the user will specify the die sides used by each player (the players can have dice with different number of sides). The user will also indicate if either or both players are using loaded dice, and will enter the number of rounds in the game. The Game class will create the necessary objects, play the game, and display the results to the user. The output results should indicate the side and type (loaded or not) of die used for each player, the number of rounds won by each player (in each round, compare the rolling results, the larger number will win), and the final winner of the game (the player that win more rounds).
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