class called Dice solved

class called Dice solved

Now, make class called Dice that has one variable called face. This variable will be a number between 1 and 6 inclusive and will store the latest value when the dice is rolled. make method called Roll that save a new value between 1 and 6 into the face variable. make another method that returns the value of face.

In the same program make a new class call Player that contains a variable called score and a variable called name. make a method called SetScore that takes as a parameter a value that is used to update the score variable. make another method called GetScore that will return the value of the score variable. Add a constructor for the player class that takes a string as input and is used to set the value of the name variable.

In the main method of the program make a dice object and three player objects.

Then roll the dice once for each player. For each roll update the score of the player with the value of the dice. So after the first three rolls each player will have a different score based on the dice.

Print the score of each player.

Roll the dice again, once for each player, print the value of the new roll and add the value of the roll to the score of each player.

Repeat this two more times, in other words, the score of each player will be the sum of 4 rolls. Remember that for each time you print the value of the roll and the total score of the player.

Finally print which player has the highest score and which player has the lowest score.
Powered by