Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please do in java Problem 2 JavaDice Design and implement an application that simulates a dice gambling game as described below. Your solution must use

Please do in java image text in transcribed
Problem 2 JavaDice Design and implement an application that simulates a dice gambling game as described below. Your solution must use methods as described. General Description of JavaDice The player starts with a fixed amount in his/her wallet (e.g. $20). To play a round of JavaDice, a player bets an amount of money (which can't exceed the amount in the wallet). The player then rolls a pair of dice, as does the opponent (the computer). Whoever rolls the best combination wins the entire pot, and a new round begins. In cases where player and computer have a tying roll, the computer wins. There are two possible combinations: Dubs: A dubs (doubles) is a combination where both dice have equal value (ke 4-4 or 6-6). The highest double combination wins. For example, a dubs of 4-4 beats 2-2. Total: If a dubs is not rolled, then the two dice are totalled. The highest total wins. For example, a 5+6 beats a 3+5. A combination of 2+6 ties a 3+5. A total combination always loses to a dubs. For example, 5-6 loses to 1-1 Implementation The program will consist of the JavaDice class containing these methods: main-the "driver" for the game. In general, it is responsible for inputing user data, displaying instructions, adjusting the amount in the wallet and displaying results. It contains a sentinel loop to input the user's bet and play multiple rounds until a negative bet is entered. It calls upon the playRound method (see below) to play each round. playRound-implements the game's logic (that is, the rules as described above). It takes the player's bet as a parameter and returns the player's winnings for a single round (either double the bet, or zero if the player loses). The amount of the bet is passed as an argument to this method. eroll-a simple method that simulates the rolling of a single die, retuming a random value from 1 to 6

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