Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In the game of Whatzee (a game of my own inventions by combining Wyman and Yhatz

ID: 3777692 • Letter: I

Question

In the game of Whatzee (a game of my own inventions by combining Wyman and Yhatzee), the player rolls two dice and the computer rolls two dice. If the player rolls double-6s, they win! Otherwise, if they roll doubles, they earn points equal 10 times the value of the dice, unless they roll "snake eyes", double ones, in which case they automatically lose. The computer follows the same scoring mechanism, but does not automatically win for double 6s.

(first java file) Write a Java program that will prompt the user for their name and then roll the dice for the player and the computer. Display a message with the point values and a descriptive message, such as "Congratulations! You win!", or "It's a tie!", or "Computer won. Better luck next time."

(2nd java file) Implement a Die class which will simulate a six-sided Die. The Die class should include appropriate instance fields (there should only be one), a constructor, accessor and mutator methods including a roll() method which will simulate rolling the die. To simulate rolling a die, you will need to generate a random number. To generate a random number, use the random() method from the Math class. Math.random() will generate a random double between 0 and 1, including 0 but not 1. To simulate rolling a die, we need to generate a random number between 1 and 6, inclusive. The following code segment simulates rolling a die:

Your main() method will need to instantiate 4 objects of the Die class. Two for the player and two for the computer.

In the Tester class, include test data to demonstrate effective testing of your program.

Explanation / Answer

import java.util.Random; 02 03 public class Die 04 { 05       private int faceValue; 06       private final int MAX=6; 07         08       public Die() 09       { 10         faceValue = 1; 11       } 12         13       //Math.random creates random integers from 1 - 6 14       public void roll() 15       { 16         faceValue = (int)(Math.random() * MAX) +1; 17       } 18         19       //Sets the face value 20       public void setFaceValue(int value) 21       { 22         faceValue=value; 23       }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote