specific Java code is a code that is going to setup the basic framework for a game of Yahtzee. In other words, you will need to understand the rules of Yahtzee and implement the rules into coding.
Hello! I am having trouble on how to write out the Java code based on the instructions (in bold //***) that I am given. As a note, this specific Java code is a code that is going to setup the basic framework for a game of Yahtzee. In other words, you will need to understand the rules of Yahtzee and implement the rules into coding. Could you also add comments to each line of code when you write out the codes for this as welI? I appreciate the help. Thanks! Also, I am using the IntelliJ IDEA application when writing out this program. Here is what I need help with:
public static void displayScoreSheet() {
final String ACES_LABEL = "Aces";
final String TWOS_LABEL = "Twos";
final String THREES_LABEL = "Threes";
final String FOURS_LABEL = "Fours";
final String FIVES_LABEL = "Fives";
final String SIXES_LABEL = "Sixes";
final String THREE_KIND_LABEL = "3 of a kind";
final String FOUR_KIND_LABEL = "4 of a kind";
final String FULL_HOUSE_LABEL = "Full House";
final String SMALL_STRAIGHT_LABEL = "Sm. Straight";
final String LARGE_STRAIGHT_LABEL = "Lg. Straight";
final String YAHTZEE_LABEL = "YAHTZEE";
final String CHANCE_LABEL = "Chance";
final String YAHTZEE_BONUS_LABEL = "YAHTZEE BONUS";
final int BONUS_THRESHOLD = 63;
final int BONUS_SCORE = 35;
final String UPPER_SECTION_LABEL = "UPPER SECTION";
final String LOWER_SECTION_LABEL = "LOWER SECTION";
final String UPPER_SECTION_SUBTOTAL_LABEL = "TOTAL SCORE";
final String UPPER_SECTION_BONUS_LABEL = "BONUS if >= 63";
final String UPPER_SECTION_TOTAL_LABEL = "TOTAL of Upper Section";
final String LOWER_SECTION_TOTAL_LABEL = "TOTAL of Lower Section";
final String GRAND_TOTAL_LABEL = "GRAND TOTAL";
final String OPTION_SUFFIX_ONE_DIGIT = ") ";
final String OPTION_SUFFIX_TWO_DIGIT = ") ";
final String FIRST_OPTION_LABEL = "1";
final String SECOND_OPTION_LABEL = "2";
final String THIRD_OPTION_LABEL = "3";
final String FOURTH_OPTION_LABEL = "4";
final String FIFTH_OPTION_LABEL = "5";
final String SIXTH_OPTION_LABEL = "6";
final String SEVENTH_OPTION_LABEL = "7";
final String EIGHTH_OPTION_LABEL = "8";
final String NINTH_OPTION_LABEL = "9";
final String TENTH_OPTION_LABEL = "10";
final String ELEVENTH_OPTION_LABEL = "11";
final String TWELFTH_OPTION_LABEL = "12";
final String THIRTEENTH_OPTION_LABEL = "13";
final String EQUALS_LABEL = " = ";
int upperScoreTotal;
upperScoreTotal = calculateUpperScore();
int lowerScoreTotal;
lowerScoreTotal = calculateLowerScore();
System.out.println();
System.out.println(UPPER_SECTION_LABEL);
if (aces == SCORE_NO_VALUE)
System.out.println(FIRST_OPTION_LABEL + OPTION_SUFFIX_ONE_DIGIT + ACES_LABEL);
else
System.out.println(FIRST_OPTION_LABEL + OPTION_SUFFIX_ONE_DIGIT + ACES_LABEL + EQUALS_LABEL + aces);
* The if-else statement continues the same way for "twos," "threes," "fours," "fives," and sixes."
if (upperScoreTotal > 0)
System.out.println(UPPER_SECTION_SUBTOTAL_LABEL + EQUALS_LABEL + upperScoreTotal);
else
System.out.println(UPPER_SECTION_SUBTOTAL_LABEL);
if (upperScoreTotal >= BONUS_THRESHOLD)
System.out.println(UPPER_SECTION_BONUS_LABEL + EQUALS_LABEL + BONUS_SCORE);
else
System.out.println(UPPER_SECTION_BONUS_LABEL);
if (upperScoreTotal > 0)
if (upperScoreTotal >= BONUS_THRESHOLD)
System.out.println(UPPER_SECTION_TOTAL_LABEL + EQUALS_LABEL + (upperScoreTotal + BONUS_SCORE));
else
System.out.println(UPPER_SECTION_TOTAL_LABEL + EQUALS_LABEL + upperScoreTotal);
else
System.out.println(UPPER_SECTION_TOTAL_LABEL);
System.out.println();
System.out.println(LOWER_SECTION_LABEL);
//***
//*** INSTRUCTIONS FOR CODE FOR YOU TO WRITE
//***
//*** 1) Following the form of the if-statement-block for option Aces (shown above):
//*** A) Write seven (7) if-statement-blocks that check the following variables for "equality to" SCORE_NO_VALUE:
//*** a) "threeKind"
//*** b) "fourKind"
//*** c) "fullHouse"
//*** d) "smallStraight"
//*** e) "largeStraight"
//*** f) "yahtzee"
//*** g) "chance"
//*** B) Use the correct Java syntax for the "equality" operator.
//***
//*** NOTE: 1) Don't forget to use the different OPTION_LABEL constants when writing the code for Step 1.
//*** 2) Starting with the tenth option (which should be Small Straight), use OPTION_SUFFIX_TWO_DIGIT for good text alignment.
//***
//*** Your code for Step 1 goes here.
//***
Trending now
This is a popular solution!
Step by step
Solved in 4 steps