Question: In java please. Make sure to include constructor for die class (returns random # between 1 and 6) roll method within the die class method

 In java please. Make sure to include constructor for die class

In java please.

Make sure to include

constructor for die class (returns random # between 1 and 6)

roll method within the die class

method getFace in die class

use of class methods in main

correct output

Thanks

Create a die class. This is similar to the coin class , but instead of face having value 0 or 1, it now has value 1,2,3,4,5, or 6. Also instead of having a method called flip, name it roll (you flip a coin but roll a die). You will NOT have a method called isHeads, but you will need a method (call it getFace ) which returns the face value of the die. Altogether you will have one attribute (face), and the following methods: constructor (calls roll), roll, getFace. Put your die class in one file and your main in another file, both in the same project. Test it by writing a main method in which you roll 2 dice. If you get exactly 7 you win, 11 you lose, anything else roll both dice again until you either win or lose. in order to verify your program works correctly put a println in the loop so that every time you roll the dice you print out the total value

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!