This is a dice game that user could roll dices and re-roll dices. Instruction: Create public class
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 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
Java How To Program Late Objects Version
ISBN: 9780136123712
8th Edition
Authors: Paul Deitel, Deitel & Associates