Need help figuring out java code

gva2145856
timer Asked: Apr 11th, 2017

Question Description

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.

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."

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: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.

User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

This question has not been answered.

Create a free account to get help with this and any other question!

Related Tags

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors