Question: Instructions: Read game rules and code provided below in Lucky7. Complete the step1() method. Once finished with step 1 : Read game rules and code
Instructions: Read game rules and code provided below in Lucky7. Complete the step1() method. Once finished with step 1: Read game rules and code provided below in Lucky7. Complete the step2() method. Copy your step1() solution from the previous lab. Once finished with step 2: Read game rules and code provided below in Lucky7. Complete the playGame() method. Copy your step1() and step2() solutions from the previous labs.
CODE PROVIDED***
import java.util.*;
/*************************************************************** 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(); game.step2(); 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(); } /********************************************************************* Update the number of credits
@param amount number of credits *********************************************************************/ public void setCredits(int amount){ if (amount >= 0){ credits = amount; } } /********************************************************************* Player continues rolling until losing a credit with a 7 or wining a credit by rolling the 'goal'. Afterwards, the goal is reset to -1 for step 1. *********************************************************************/ public void step2(){ // insert your code here } /********************************************************************* 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
} /********************************************************************* @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; } /********************************************************************* Return one of two dice for the GUI
@param num identify which dice to return @return the requested die *********************************************************************/ // public GVdie getDie(int num){ // GVdie d; // if (num == 1){ // d = d1; // }else{ // d = d2; // } // return d; // } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
