Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The Game50 dice game is described in the textbook. Here is the partially written

ID: 3815252 • Letter: T

Question

The Game50 dice game is described in the textbook. Here is the partially written Game50 class, public class Game50{static final int SIZE = 50; // target score to be exceeded private int bound; // number of allowable rolls to reach 50 private int rollCount; // number of rolls private int total; // accumulated dice roll sum private boolean winner; // game a win or loss? public Game50(int rollBound){bound = rollBound; // rollBound value supplied in constructor call in driver class} public void playGame(){initializeGame(); while(!gameOver()){advancePlay(); showGame();} judgeAndReport();} In the answer box below, enter code that implements the code for the Game50 for the private method roll.

Explanation / Answer

Private Method roll function definition:

//Method that returns the outcome of a roll
private int roll()
{
   //Variable to hold outcome of a dice roll
   int outcome;
  
    //Rolling a single dice (Outcomes might be any number between 1 and 6 both inclusive)
   //(int)(Math.random()*6) + 1 function will return a random value between 1 and 6 both inclusive
   outcome = (int)(Math.random()*6) + 1;
  
   //Returning outcome
   return outcome;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote