Question: This is a dice game that user could roll dices and re-roll dices. Instruction: Create public class DiceGame: - public DiceGame() - a zero argument


This is a dice game that user could roll dices and re-roll dices.


Instruction:

Create public class DiceGame:


- public DiceGame() - a zero argument constructor which should initialize a new DiceHand instance and "roll" a set of five six-sided dice and store the result as an instance variable.


- public DiceGame(int[] dice) - a constructor which should set the instance variable for the dice roll to the supplied value


- public void Rerolls(int[] rerolls) - an instance method which "re-rolls" dice with the specified values. Dice are identified by value. Note: ignore incorrect inputs


- A main method implements a playable game where the user plays through 3 rounds and is allowed one opportunity to re-roll any dice after each round result is displayed.



Sample output:

2 5 6 2 3

what numbers to re-roll(separated by space): 2 3

4 5 6 2 1


2 5 6 2 3

what numbers to re-roll(separated by space): 7

2 5 6 2 3


2 5 6 2 3

what numbers to re-roll(separated by space): 2 2

5 5 6 1 3









Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Here is a sample implementation of the DiceGame class with the specified m... View full answer

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 Programming Questions!