isted on the following page is a Dice elass that simulates rolling a die with a
ID: 3908833 • Letter: I
Question
isted on the following page is a Dice elass that simulates rolling a die with a different number of sides. The default is a standard die with six sides. The rollTwoDice function simulates rolling two dice objects and returns the sum of their values. A driver program is shown that simulates a dice game by rolling a pair of dice 10 times. In the space below, create your own class LoadedDice that is derived from Dice, with the following requirements: Provide a default constructor, and a constructor that takes the number of sides as input. Recall that a derived class constructor should call the corresponding base class constructor in order to initialize base class member variables. . Override the roll Dice function so that with a 50% probability the function returns the largest number possible (i.e., nums ides), and with a50% probability returns what Dice's rollDice function returns. · .Indicate the change that must be made to the rol1D.ce function in the Dice class so that the rol1lDice function in the LoadedDice class will be called in all appropriate next page.) (rand () % 2--0) // returns true if the random number is an even num circumstances. (You may write your change directly in the listing of the Dice class on Hint: The following relational expression can be used to generate a 50-50 probability:Explanation / Answer
the above code should be in class LoadedDice, i do not understand any reason to make changes in rollDice() method in the base class because both variants are different. The parent class do not know anything about the child class, so we can not call the child class method from parent class. Thanks!
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.