public class YahtzeeP1 {        final static int SCORE_NO_VALUE = -1;        static int aces = SCORE_NO_VALUE;        static int twos = SCORE_NO_VALUE;        static int threes = SCORE_NO_VALUE;        static int fours = SCORE_NO_V

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Hello! I am having trouble trying to write out the code that is supposed to begin by creating the "framework" of my Yahtzee Java program and I am just not sure on how to go about it. There are instructions (//***) at the very end of the code on what I have to write out, but that is where I am having trouble. Can you also write the comments that explains the "why" and "how" for each code as well? Thanks and I appreciate it. Here is what I have so far:

public class YahtzeeP1 {
       final static int SCORE_NO_VALUE = -1;

       static int aces = SCORE_NO_VALUE;
       static int twos = SCORE_NO_VALUE;
       static int threes = SCORE_NO_VALUE;
       static int fours = SCORE_NO_VALUE;
       static int fives = SCORE_NO_VALUE;
       static int sixes = SCORE_NO_VALUE;

       static int threeKind = SCORE_NO_VALUE;
       static int fourKind = SCORE_NO_VALUE;
       static int fullHouse = SCORE_NO_VALUE;
       static int smallStraight = SCORE_NO_VALUE;
       static int largeStraight = SCORE_NO_VALUE;
       static int yahtzee = SCORE_NO_VALUE;
       static int chance = SCORE_NO_VALUE;

       static int yahtzeeBonusCount = SCORE_NO_VALUE;

       final static int YAHTZEE_SCORE = 50;
       final static int YAHTZEE_BONUS_SCORE = 100;

       final static String BORDER_CHAR = "*";

       final static String INVALID_INPUT_MESSAGE = "*** Invalid input ***";

       final static int NUMBER_OF_CATEGORIES = 13;

       static int die1;
       static int die2;
       static int die3;
       static int die4;
       static int die5;

       static int turnCount = 0;
       static int numberOfRolls = 0;

       public static void main(String[] args) {

              final int MAX_NUMBER_ON_DIE = 6;

              final int MAX_NUMBER_ROLLS = 3;

              final String WELCOME_MESSAGE = "Welcome to YAHTZEE";

              final String PRESS_ENTER_MESSAGE = "Press the Enter key to continue: ";

              final String REROLL_MESSAGE_1 = "Enter: S for ScoreCard; D for Dice; X to Exit";
              final String REROLL_MESSAGE_2 = "Or: A series of numbers to re-roll dice as follows:";
              final String REROLL_MESSAGE_3 = "\t\tYou may re-roll any of the dice by entering " +
                         "the die #s without spaces.";
              final String REROLL_MESSAGE_4 = "\t\tFor example, to re-roll dice #1, #3 & #4, " +
                         "enter 134 or enter 0 for none.";
              final String REROLL_MESSAGE_5 = "You have %d roll(s) left this turn.";
              final String REROLL_MESSAGE_6 = "Which of the dice would you like to roll again? ";

              final String CATEGORY_MESSAGE_1 = "Enter: 1-" + NUMBER_OF_CATEGORIES +
                         "for category; S for ScoreCard; D for Dice; X to Exit";
              final String CATEGORY_MESSAGE_2 = "Which category would you like to choose? ";

              boolean turnOver = false;

              boolean gameExit = false;

              boolean gameComplete = false;

              String dice2Reroll;

              char die2Reroll;

              String scoreOptionInput;

              int scoreOption = 0;

              Scanner input = new Scanner(System.in);

               long seed = (new java.util.Date()).getTime();
               Random generator = new Random(seed);

               System.out.println();
               System.out.println(WELCOME_MESSAGE);

               do {
                    System.out.println();
                    System.out.print(PRESS_ENTER_MESSAGE);

                     input.nextLine();

                     turnCount++;

                     die1 = generator.nextInt(MAX_NUMBER_ON_DIE) + 1;
                     die2 = generator.nextInt(MAX_NUMBER_ON_DIE) + 1;
                     die3 = generator.nextInt(MAX_NUMBER_ON_DIE) + 1;
                     die4 = generator.nextInt(MAX_NUMBER_ON_DIE) + 1;
                     die5 = generator.nextInt(MAX_NUMBER_ON_DIE) + 1;

                     numberOfRolls = 1;

                     displayDice();

                     turnOver = false;

                     do {

                          System.out.println();
                          System.out.println(REROLL_MESSAGE_1);
                          System.out.println();

                          System.out.println(REROLL_MESSAGE_2);
                          System.out.println(REROLL_MESSAGE_3);
                          System.out.println(REROLL_MESSAGE_4);

                          System.out.println();
                          System.out.printf(REROLL_MESSAGE_5, (MAX_NUMBER_ROLLS - numberOfRolls));
                          System.out.println();

                          System.out.println();
                          System.out.print(REROLL_MESSAGE_6);

                          dice2Reroll = input.nextLine().trim();

//*** INSTRUCTIONS FOR CODE FOR YOU TO WRITE (Included within the uploaded image)

File Edit View Navigate Code Refactor Build Run Iools VCS Window Help
Yahtzee - Project 1 - Yahtzee - Project 1.java
Yahtzee - Project 1 src
YahtzeeP1
m main
Add Configuration...
G Yahtzee - Project 1.java
271
//*** 1) Write the switch-expression for the switch statement on line 300.
O 35 A 42 V 38 ^
272
//***
A) The expression must:
273
//***
a) Use the variable "dice2Reroll".
274
//***
b) Invoke the "toUpperCase" method on variable "dice2Reroll".
275
> ||
//***
c) Pass no arguments to method "toUpperCase".
276
//***
B) See Chapter 4 Section 4.4 (4.4.1 - 4.4.10) in the
277
//***
textbook for treatment of the "toUpperCase" method.
278
//***
279
//*** 2) The cases being "X", "S", "D", "0", and ""
280
//***
A) When case "X":
281
//***
a) Write a statement that assigns the value of true
282
//***
to the variable "turnOver".
b) Write a statement that assigns the value of true
***//
//***
283
284
to the variable "gameExit".
285
//***
B) When case "S":
286
//***
a) Call method "displayScoreSheet" passing no arguments.
287
//***
c) When case "D":
288
//***
a) Call method "displayDice" passing no arguments.
289
//***
D) When case "0" (this is number zero, not letter 0):
290
//***
a) Write a statement that assigns the value of true
291
//***
to the variable "turnOver".
292
//***
E) When case "" (this is empty quotes; there is no space
293
//***
between the quotes):
294
//***
a) Call method "displayErrorMessage" passing no arguments.
295
//***
P Version Control
E TODO
e Problems
2 Terminal
1 Event Log
O Download pre-built shared indexes: Reduce the indexing time and CPU load with pre-built JDK shared indexes // Always download // Download once // Don't show agai. (yesterday 11:34 PM)
268:17 CRLF UTF-8 4 spaces
2:57 AM
IJ
O Type here to search
Rain...
2/23/2022
Project
Bookmarks
i. Structure
...
Transcribed Image Text:File Edit View Navigate Code Refactor Build Run Iools VCS Window Help Yahtzee - Project 1 - Yahtzee - Project 1.java Yahtzee - Project 1 src YahtzeeP1 m main Add Configuration... G Yahtzee - Project 1.java 271 //*** 1) Write the switch-expression for the switch statement on line 300. O 35 A 42 V 38 ^ 272 //*** A) The expression must: 273 //*** a) Use the variable "dice2Reroll". 274 //*** b) Invoke the "toUpperCase" method on variable "dice2Reroll". 275 > || //*** c) Pass no arguments to method "toUpperCase". 276 //*** B) See Chapter 4 Section 4.4 (4.4.1 - 4.4.10) in the 277 //*** textbook for treatment of the "toUpperCase" method. 278 //*** 279 //*** 2) The cases being "X", "S", "D", "0", and "" 280 //*** A) When case "X": 281 //*** a) Write a statement that assigns the value of true 282 //*** to the variable "turnOver". b) Write a statement that assigns the value of true ***// //*** 283 284 to the variable "gameExit". 285 //*** B) When case "S": 286 //*** a) Call method "displayScoreSheet" passing no arguments. 287 //*** c) When case "D": 288 //*** a) Call method "displayDice" passing no arguments. 289 //*** D) When case "0" (this is number zero, not letter 0): 290 //*** a) Write a statement that assigns the value of true 291 //*** to the variable "turnOver". 292 //*** E) When case "" (this is empty quotes; there is no space 293 //*** between the quotes): 294 //*** a) Call method "displayErrorMessage" passing no arguments. 295 //*** P Version Control E TODO e Problems 2 Terminal 1 Event Log O Download pre-built shared indexes: Reduce the indexing time and CPU load with pre-built JDK shared indexes // Always download // Download once // Don't show agai. (yesterday 11:34 PM) 268:17 CRLF UTF-8 4 spaces 2:57 AM IJ O Type here to search Rain... 2/23/2022 Project Bookmarks i. Structure ...
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY