It is to make a dice

Anonymous
timer Asked: Nov 28th, 2016

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:

int ran = 1 + (int) (Math.random() * 6);

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

Include authorship comments at the top of your code.  In the Tester class, include test data to demonstrate effective testing of your program.


2ND ASSIGNMENT This assignment is optional. It is intended to make-up for points lost earlier in the semester due to illness or other life events getting in the way of class. For this assignment, create a dice game that uses at least two classes. One will be a Die class that will simulate a 6-sided die. The program should simulate a dice game that rolls 5 dice for a player and 5 dice for the computer - the player's opponent. Use an array to keep track of the dice. If the player rolls 5 of a kind, they win. Otherwise, the scoring is as follows: Roll Points 4 of a kind 40 3 of a kind 30 2 of a kind 20 straight (all numbers in sequence) 35 For both the computer and the player, display the value of the dice, the points earned by each and who won. Include your name as a comment at the top of your Tester class as well as a description of how you tested this program to make sure it works.

Studypool has helped 1,244,100 students
flag Report DMCA
Similar Questions
Hot Questions
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