Question: **Read game rules and code provided below in Lucky7. Complete the step1() method. /*************************************************************** Simulates a dice game called Lucky 7. Step 1: The player

**Read game rules and code provided below in Lucky7. Complete the step1() method.

/*************************************************************** Simulates a dice game called Lucky 7.

Step 1: The player rolls two dice and wins by rolling a 7 or 11; loses by rolling 2, 3 or 12; or the sum of both dice become the 'goal' for step 2.

Step 2: The player continues rolling both dice until losing with a seven or winning by rolling the 'goal'. @author Scott Grissom @version January 20, 2018 **************************************************************/ public class Lucky7{

/** the goal during step 2 */ private int goal; /** total credits */ private int credits; /** two dice for the game */ private GVdie d1, d2;

public static void main(String args[]){ Lucky7 game = new Lucky7(); game.step1(); System.out.println("Credits: " + game.getCredits()); System.out.println("Goal: " + game.getGoal()); }

/********************************************************************* Constructor *********************************************************************/ public Lucky7(){ credits = 10; goal = -1; d1 = new GVdie(); d2 = new GVdie(); } /********************************************************************* First roll of the round. Player wins one credit by rolling 7 or 11. Loses one credit by rolling 2, 3 or 12. All other rolls determine the 'goal' for step 2.

Player must have at least one credit and goal == -1. *********************************************************************/ public void step1(){ // insert your code here

} /********************************************************************* Update the number of credits

@param amount number of credits *********************************************************************/ public void setCredits(int amount){ if (amount >= 0){ credits = amount; } } /********************************************************************* @param s1 random seed for die 1 (for testing) @param s2 random seed for die 2 (for testing) *********************************************************************/ public void setSeeds(int s1, int s2){ d1.setSeed(s1); d2.setSeed(s2); }

/********************************************************************* @return current number of credits *********************************************************************/ public int getCredits(){ return credits; }

/********************************************************************* @return the current goal *********************************************************************/ public int getGoal(){ return goal; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!