Question: Write a program using three static methods to simulate rolling one dice with six sides containing values 1-6. Roll the dice until the roll results
Write a program using three static methods to simulate rolling one dice with six sides containing values 1-6. Roll the dice until the roll results in three consecutive odd values.
Identify the lucky status of a player.
lucky (3 rolls)
somewhat lucky (4 6 rolls)
unlucky (more than 6 rolls)
You may select between two options for writing this program.
Option #1: Write Java Code to program the game using static methods and variables
public static return type instructions( );//displays the Game information
public static return type playGame( )//generates the random dice roll value in the range of 1-10
public static return type displayResults( ) //displays the dice roll and the lucky staus (lucky, somewhat lucky, unlucky) Call the static methods in the main method
Option #2: Write Java Code to program the game using a Java Implementation class DiceRoll.java and a Tester Class DiceRollTester.java The Implementation class contains three methods as described above.
instructions()
playGame()
displayResults()
DiceRollTester.java class instantiates an object of the DiceRoll.java class and calls the methods of the class to play the game.
Outpu
t Dice Rolls:1,2,1,2,1,2,3,1,4,5,5,1,
It took 12 rolls to obtain three consecutive odd rolls. Unlucky walk away!
Dice Rolls: 5,5,1
It took 3 rolls to obtain three consecutive odd rolls. Lucky!
Dice Rolls:1,2,3,4,2,1,2,5,2,4,1,3,5,
It took 13 rolls to obtain three consecutive odd rolls. Unlucky walk away!
Dice Rolls: 4,5,3,3, It took 4 rolls to obtain three consecutive odd rolls. Sort of Lucky!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
