Question: 4 (40 points): Write a game named VersusGame that rolls for the computer and rolls for the player. The game compares the values of each

 4 (40 points): Write a game named VersusGame that rolls for
the computer and rolls for the player. The game compares the values

4 (40 points): Write a game named VersusGame that rolls for the computer and rolls for the player. The game compares the values of each individual die of the computer roll to the value at the index of player rolls. If the player gets the same value or greater than the computer, they win the roll. If the player wins 50% or more of all the rolls, they win the round. If you look at the first roll in the screenshot below, the computer rolled 3,4,3,2 and the player rolled 4,6,5,3. 4 beats 3, 6 beats 4, 5 beats 3 and 3 beats 2. The player won 100% of the rolls winning the round. This game was initialized with a DiceShaker that had 4 dice. >>> g.roll() Computer rolled: [3, 4, 3, 2) Player rolled: (4, 6, 5, 3] You win! You had 100.0% values (4 of 4) greater than or equal to the computer. >>> g.roll() Computer rolled: (4, 2, 6, 1] Player rolled: [4, 3, 5, 4] You win! You had 75.0% values (3 of 4) greater than or equal to the computer. >>> g.roll() Computer rolled: [6, 5, 3, 5) Player rolled: (5, 2, 4, 5] You win! You had $0.0% values (2 of 4) greater than or equal to the computer. >>> g.roll() Computer rolled: (2, 1, 1, 3) Player rolled: (6, 1, 5, 21 You win! You had 75.06 values (3 of 4) greater than or equal to the computer. Methods to implement: a. __init_(ds): Constructor. Initializes the class with a mandatory DiceShaker as a parameter. b. roll() : Shakes the Dice Shaker and used to retrieve the face value of the dice and check if the player won. See messages below. c. getGameCount(): returns an int with the total games played (calls to rollo) d. getScore(): returns an int with the total of games won. Example with a dice Shaker that has 8 die. >>> da-DiceShaker (8) >>> VersusGame (ds) >>> Q.2011) Computer olied: [3, 22, 2, 6, 2, 5, 5) Player rolled: [2, 6, 3, 2, 6, 5, 1, 61 You win! You had 75.0+ values (6 of 8) greater than or equal to the computer. >>>> 9.xoli () Computer rolled: (4, 2, 3, 4, 5, 6, 3, 61 Player rolled: (2, 4, 4, 2, 3, 2, 2, 3) You win! You had 25.00 values 12 EB) greater than or equal to the computer. >>> g.xoll() Computer rolled: (3, 6, 5, 1, 5, 5, 4, 3) Player rolled: [6, 2, 1, 1, 5, 4, 61 You win! You had 50.01 Value (018) greater than or equal to the computer. >>> dizoli) Computer tolled: [3, 1, 5, 5, 4, 5, 5, 3] Player Folied: 5, 3, 5, 2, 3, 4, 3, 5) You win! You had 50.0% values (4 of 8) greater than or equal to the computer. >>> G.2011 Computex rolled: [2, 2, 1, 1, 2, 2, 2) Player rolled: [1, 6, 1, 4, 6, 4, 6, 4) You win! You had 75.06 values (6 of 8) greater than or equal to the computer. >>> 9.rollo Computer rolled: [4, 2, 5, 2, 2, 2, 3, 4) Player rolled: (2, 5, 3, 3, 2, 2, 2, 3] You win! You had 50.06 values (4 of 8) greater than or equal to the computer. >>> g.getScore() 6 >>>> d.getGameCount() 6

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!