Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Has to be done in Java Question 6. Write a simple press-your-luck dice game. The game works as follows: .Player 1 starts with a score

Has to be done in Java image text in transcribed
Question 6. Write a simple press-your-luck dice game. The game works as follows: .Player 1 starts with a score of zero and rolls two dice o If the player rolls 7, 2, or 12 their turn is over and they lose. o If the player rolls any other sum it is added to their total score. o The player can stop rolling at any time remember if their last roll was a 7, 2 or 12 they lose and Player 2 wins After Player 1 stops rolling, Player 2 rolls the two dice o Player 2 continues to roll the dice until they roll a 7, 2 or 12 (Player 2 loses) or they have a total higher than Player 1 (Player 2 wins). Your solution should make use of methods with the following headers: . public static int rollDie ) o return a random valid die value between 1 and 6 .public static int newscore (int oldscore, int rollValue) o determine if the current roll should be added to the score. If the player rolled 7, 2 or 12 return -1 to show that the player just lost. Otherwise return the updated score. .public static int whoGoesFirst) o randomly return 1 if player 1 goes first or 2 if player 2 goes first . public static String winner (int playerNumber) o print a message indicating who won the game . public static char keepRolling 0 o A method that prompts the player to ask if they want to keep rolling. Return y or n as needed. Note: Player 2 could- stop rolling if they wanted to but if they haven't achieved a higher score they will lose. . main () o this is your main method that coordinates all of the other methods as necessary. Collect all input and produce all output from this method. Your game should be able to play a complete human vs. human game. No sample output. Be creative (but kind to your users). You should be able to play human vs. computer AND play multiple games without quitting the program (a while loop) AND keep track of how many games each player has won (a couple of variables that get updated and displayed at the end of each game)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions