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. 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: * The code given below is going to be modified based on the instructions in bold. // These are the declared die values. static int die1, die2, die3, die4, die5; public static int calculateFullHouse() { int score; score = 0; boolean isFullHouse; isFullHouse = false; System.out.println("In method calculateFullHouse"); return score; } //*** INSTRUCTIONS FOR CODE FOR YOU TO WRITE //*** //*** Modify your "calculateFullHouse" method as follows: //*** 1) Remove the System.out.println statement. //*** //*** 2) Write an if-statement that checks if the player has Yahtzee. //*** NOTE: Yahtzee is not a Full House. //*** A) Consider the definition of a Full House, which is: //*** "Three of one number and two of a different number" //*** B) The if-statement condition for Step 2 must call method //*** "calculateYahtzee" and check for "equality to" 0 (zero). //*** //*** 3) Inside the if-statement in Step 2, nest the following: //*** A) Create an if-else-if structure to determine if the five (5) //*** dice form a valid Full House. //*** B) You MUST use an if-else-if structure. //*** C) Your if-statement conditions MUST be compound Boolean expressions. //*** In other words, the if-statement conditions must have multiple //*** expressions joined by && (AND) or || (OR) operators. //*** //*** 4) In your if-else-if structure, if it is determined that the //*** configuration of the dice form a valid Full House, then assign //*** the value of true to the variable "isFullHouse". //*** //*** 5) Not connected to nor nested within the if-statement in Step 2, //*** write an if-statement that checks if variable "isFullHouse" is true. //*** //*** 6) Code block for if-statement in Step 5: //*** A) Assign the value of FULL_HOUSE_SCORE to variable "score". //*** //*** 7) Keep the return statement that returns the variable "score". //*** //*** Hint: Here are the combinations of dice that form a valid Full House: //*** 1) Variables "die1", "die2" and "die3" are equal, and variables "die4" and "die5" are equal //*** 2) Variables "die2", "die3" and "die4" are equal, and variables "die1" and "die5" are equal //*** 3) Variables "die3", "die4" and "die5" are equal, and variables "die1" and "die2" are equal //*** 4) Variables "die1", "die3" and "die5" are equal, and variables "die2" and "die4" are equal //*** 5) Variables "die1", "die3" and "die4" are equal, and variables "die2" and "die5" are equal //*** 6) Variables "die1", "die4" and "die5" are equal, and variables "die2" and "die3" are equal //*** 7) Variables "die1", "die2" and "die4" are equal, and variables "die3" and "die5" are equal //*** 8) Variables "die1", "die2" and "die5" are equal, and variables "die3" and "die4" are equal //*** 9) Variables "die2", "die3" and "die5" are equal, and variables "die1" and "die4" are equal //*** 10) Variables "die2", "die4" and "die5" are equal, and variables "die1" and "die3" are equal
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. 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:
* The code given below is going to be modified based on the instructions in bold.
// These are the declared die values.
static int die1, die2, die3, die4, die5;
public static int calculateFullHouse() {
int score;
score = 0;
boolean isFullHouse;
isFullHouse = false;
System.out.println("In method calculateFullHouse");
return score;
}
//*** INSTRUCTIONS FOR CODE FOR YOU TO WRITE
//***
//*** Modify your "calculateFullHouse" method as follows:
//*** 1) Remove the System.out.println statement.
//***
//*** 2) Write an if-statement that checks if the player has Yahtzee.
//*** NOTE: Yahtzee is not a Full House.
//*** A) Consider the definition of a Full House, which is:
//*** "Three of one number and two of a different number"
//*** B) The if-statement condition for Step 2 must call method
//*** "calculateYahtzee" and check for "equality to" 0 (zero).
//***
//*** 3) Inside the if-statement in Step 2, nest the following:
//*** A) Create an if-else-if structure to determine if the five (5)
//*** dice form a valid Full House.
//*** B) You MUST use an if-else-if structure.
//*** C) Your if-statement conditions MUST be compound Boolean expressions.
//*** In other words, the if-statement conditions must have multiple
//*** expressions joined by && (AND) or || (OR) operators.
//***
//*** 4) In your if-else-if structure, if it is determined that the
//*** configuration of the dice form a valid Full House, then assign
//*** the value of true to the variable "isFullHouse".
//***
//*** 5) Not connected to nor nested within the if-statement in Step 2,
//*** write an if-statement that checks if variable "isFullHouse" is true.
//***
//*** 6) Code block for if-statement in Step 5:
//*** A) Assign the value of FULL_HOUSE_SCORE to variable "score".
//***
//*** 7) Keep the return statement that returns the variable "score".
//***
//*** Hint: Here are the combinations of dice that form a valid Full House:
//*** 1) Variables "die1", "die2" and "die3" are equal, and variables "die4" and "die5" are equal
//*** 2) Variables "die2", "die3" and "die4" are equal, and variables "die1" and "die5" are equal
//*** 3) Variables "die3", "die4" and "die5" are equal, and variables "die1" and "die2" are equal
//*** 4) Variables "die1", "die3" and "die5" are equal, and variables "die2" and "die4" are equal
//*** 5) Variables "die1", "die3" and "die4" are equal, and variables "die2" and "die5" are equal
//*** 6) Variables "die1", "die4" and "die5" are equal, and variables "die2" and "die3" are equal
//*** 7) Variables "die1", "die2" and "die4" are equal, and variables "die3" and "die5" are equal
//*** 8) Variables "die1", "die2" and "die5" are equal, and variables "die3" and "die4" are equal
//*** 9) Variables "die2", "die3" and "die5" are equal, and variables "die1" and "die4" are equal
//*** 10) Variables "die2", "die4" and "die5" are equal, and variables "die1" and "die3" are equal
Trending now
This is a popular solution!
Step by step
Solved in 2 steps