(a) Create a Java class named RiskyDice (b) For this lab, I am providing you with...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
(a) Create a Java class named RiskyDice (b) For this lab, I am providing you with the main method, as shown here: public static void main(String[] args) { int pg = determine Play() ; if (pg != -1) { playGame (pg); } } (c) Above the main method, create a Random object. Make it a public static object, so that we can use it in any of our methods. (d) For this lab, we are making a dice game. You must first prompt the user for whether or not they wish to play the game. If the user does not want to play, exit. Otherwise, your program must simulate rolling a pair of dice between 3 to 5 times, as specified by the user. If the user specifies a number of rolls below 3, or above 5, you must re-prompt the user until they provide an appropriate number of rolls. After the rolls are complete, a single match means the user wins, otherwise the computer wins. (e) Your program needs the following methods that perform the following actions: determinePlay o determinePlay should return an integer and take no arguments o determinePlay should first ask if the user wants to play the game. You can use console input with a Scanner, or a JOptionPane InputDialog. If the user wants to play, determinePlay should prompt the user for the number of times they want to roll dice, between 3 and 5. If invalid input is O provided, prompt the user of their error and try again until receiving valid input. o After getting the number of times the dice will be rolled, the method should return that number. o If the user doesn't want to play, return -1 to quit, as shown in the provided main method • playGame a. playGame should have no return type b. playGame should take the number of times the dice will be rolled as an argument c. playGame should use a method called rollDice to roll two dice d. rollDice should be called and checked, as many times as the user specified, using a for loop e. In the dice ever match, the game should end with the player's victory f. If none of the rolls match, the game should end with the player's loss g. This method MUST use System.exit(0) to end the program when the user has won or lost rollDice a. rollDice takes no argument b. rollDice should roll two dice using the Random object (that is, generate two numbers between 1 and 6, both inclusive) c. If the dice match, the player wins and the playGame method should terminate the program. Note that this function is invoked in the playGame function. d. It is up to you to choose what return type rollDice has – it should be clear whether or not the dice matched through whatever return value you use. (f) Feel free to add more methods, if you feel a need for it. For example, you could have a method to get the random dice roll value. (a) Create a Java class named RiskyDice (b) For this lab, I am providing you with the main method, as shown here: public static void main(String[] args) { int pg = determine Play() ; if (pg != -1) { playGame (pg); } } (c) Above the main method, create a Random object. Make it a public static object, so that we can use it in any of our methods. (d) For this lab, we are making a dice game. You must first prompt the user for whether or not they wish to play the game. If the user does not want to play, exit. Otherwise, your program must simulate rolling a pair of dice between 3 to 5 times, as specified by the user. If the user specifies a number of rolls below 3, or above 5, you must re-prompt the user until they provide an appropriate number of rolls. After the rolls are complete, a single match means the user wins, otherwise the computer wins. (e) Your program needs the following methods that perform the following actions: determinePlay o determinePlay should return an integer and take no arguments o determinePlay should first ask if the user wants to play the game. You can use console input with a Scanner, or a JOptionPane InputDialog. If the user wants to play, determinePlay should prompt the user for the number of times they want to roll dice, between 3 and 5. If invalid input is O provided, prompt the user of their error and try again until receiving valid input. o After getting the number of times the dice will be rolled, the method should return that number. o If the user doesn't want to play, return -1 to quit, as shown in the provided main method • playGame a. playGame should have no return type b. playGame should take the number of times the dice will be rolled as an argument c. playGame should use a method called rollDice to roll two dice d. rollDice should be called and checked, as many times as the user specified, using a for loop e. In the dice ever match, the game should end with the player's victory f. If none of the rolls match, the game should end with the player's loss g. This method MUST use System.exit(0) to end the program when the user has won or lost rollDice a. rollDice takes no argument b. rollDice should roll two dice using the Random object (that is, generate two numbers between 1 and 6, both inclusive) c. If the dice match, the player wins and the playGame method should terminate the program. Note that this function is invoked in the playGame function. d. It is up to you to choose what return type rollDice has – it should be clear whether or not the dice matched through whatever return value you use. (f) Feel free to add more methods, if you feel a need for it. For example, you could have a method to get the random dice roll value.
Expert Answer:
Answer rating: 100% (QA)
Heres the implementation of the RiskyDice class based on the provided requirements java import javau... View the full answer
Related Book For
Java How To Program Late Objects Version
ISBN: 9780136123712
8th Edition
Authors: Paul Deitel, Deitel & Associates
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Identify the process evaluation article that you chose and explain why you selected this example. Describe the purpose of the evaluation, the informants, the questions asked, and the results of the...
-
A project is proposed to design a database for shops selling dairy products. Each shop has a unique ID, name, address and owner. Different shops could be owned by the same owner. Each shop sells...
-
Bearland Manufacturing produces 4 different types of wood paneling. Each type of paneling is made by gluing and pressing together a different mixture of pine and oak chips. The following table...
-
a: What are the appropriate methods to coordinate the operation of all consultative processes? Answer in 50-100 words. b: Outline twelve (12) consultative processes that you need to coordinate in the...
-
The capital structure of Audiology Associates, Inc., at December 31, 2007 , included 5,000 shares of \(\$ 2\) preferred stock and 100,000 shares of common stock. Common shares outstanding during 2008...
-
Townsend Industries Inc. manufactures recreational vehicles. Townsend uses a job order cost system. The time tickets from November jobs are summarized as follows: Job...
-
Crafty Corporation received $471,068 of cash upon issuance of 500, $1,000 par value bonds. Each bond has a stated rate of 4% and will mature on December 31, 2030, 7 years after the issuance of the...
-
Hatfield Medical Supplys stock price had been lagging behind its industry averages, so its board of directors brought in a new CEO, Jaiden Lee. Lee had brought in Ashley Novak, a finance MBA who had...
-
Evaluate economic conditions that influence company performance. Consider political, environmental, currency (money), global economics, and government influences on economic conditions. Compare...
-
Superior Company provided the following data for the year ended December 31 (all raw materials are used in production as direct materials): Selling expenses Purchases of raw materials Direct labor...
-
Alice visited her local police station in response to Detective Barker's request that Alice meets with him at her convenience. The Detective wanted to discuss a series of burglaries that had occurred...
-
Riddle Ltd (Riddle) operates a gold mine in Western Australia. It has four members who are Harold (who holds 30% of the shares), Gary (who holds 30% of the shares), Marie (who holds 30% of the...
-
QUESTION TWO (20 MARKS) The data below gives the concentration of copper in tissues of a given plant: (a) (b) Leave 35 42 60 22 39 75 52 78 56 36 17 69 25 32 48 5 46 3 S Roots 40 51 71 29 49 89 62 77...
-
Sam and Sue are shopping for groceries. Sam looks at the list and tells Sue, "I'll get the cat food, soap, toilet paper, and flour, and I'll meet you by the lettuce." Sam takes off, muttering to...
-
A light ray falls on a square glass slab with an angle ofincidence of 45 degrees as in the figure below. What must be the index of refraction of the glass if total internalreflection occurs at the...
-
Prepare a stock card using the following information A company is registered for GST which it pays quarterly, assume GST was last paid on the 30th of June 2019. It uses weighted average cost...
-
Write a program that inserts 25 random integers from 0 to 100 in order into a linked-list object. For this exercise, youll need to modify the List class (Fig. 21.3) to maintain an ordered list. Name...
-
Some people want to eliminate sexism in all forms of communication. Youve been asked to create a program that can process a paragraph of text and replace gender-specific words with gender-neutral...
-
Write a recursive method recursiveMinimum that determines the smallest element in an array of integers. The method should return when it receives an array of one element.
-
Is the color of a smartphone nominal or ordinal?
-
A pollster wants to estimate the proportion of voters in a certain town who are Democrats. He goes to a large shopping mall and approaches people to ask whether they are Democrats. Is this a simple...
-
Provide an example of a qualitative variable and an example of a quantitative variable.
Study smarter with the SolutionInn App