Question
3. (Die.java and DiceTester.java) Implement a class used to simulate a die (singular of dice). Your class should have two data fields, one to store
3. (Die.java and DiceTester.java) Implement a class used to simulate a die (singular of dice). Your class should have two data fields, one to store the number of sides on your die and another to store which side (value) is currently facing up. Your class should have two constructors one that takes zero arguments and creates a standard 6-sided die and a second constructor that takes a single argument. The argument should allow the user to create a die that has 4, 6, 8, 10, 12, 20 or 100 sides; if the user enters any other value then the die should default to 6 sides. Both constructors should leave the side-up data field with a random (but valid) value. Your class should have a single accessor (getValue()) that returns the current value facing up. Your class should have a single void mutator method (roll()) that randomly rolls the die make use of your number of sides data field here. Finally, add a toString() method to make it easy to print out the state of your die objects. Write a complete tester program to show that your die class is fully functional. In particular, you should create at least two dice, one with each constructor (get user input for the constructor that takes an argument, dont do any input checking). Then roll them independently singly and using a loop. Also, since many games use more than one die show the sum of all your dice objects. ***Write JavaDoc comments for this class.***
Please write a complete and working solution of both the tester and the Java class required to run the program. Here is the sample output: I want the out put with this part: Creating two dice - one with user input, enter number of sides for the second one: user input
Die[user inputted sides, value = ?]
Die[user inputted sides, value = ?]
Rolling and printing:
Die 1 showing:
Die 2 showing:
Sum of Dice
Creating two dice one with 6 sides, enter number of sides for the second one 20 Die 6 sides value 31 Die C20 sides value 111 Rolling each separately and printing the values Die 1 showing 6 Die 2 showing 3 Sum of the dice: 9 for loop to roll the two dice 10 times and show the values and the sum Die 2 Die 1. Sum 13 17 18 17 10 15 19 22 16 12 11Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started