Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is a dice game (each roll uses four die = 4 dice) that you are going to create in the command line console. The

This is a dice game (each roll uses four die = 4 dice) that you are going to create in the command line console. The rules are as follows: A new player begins with his first dice roll (4 die = 1 set of dice). This is known as the "starting roll." o If the player rolls a 9, 11, 18, or 24 the player wins. o If the player rolls a 6, 12, 13, 17, 19, or 23 the player loses. o If the player rolls any other number, the "starting roll" becomes the "goal number."

The player must continue to roll the dice until either one of two things happens: The player rolls a 13, and he loses. The player rolls the "goal number" again, and he wins. 1. In your main method: Produce a customized welcome message in the command console that will be your starting point for this program. Ask your end user for his or her name, and include a customized message saying hello to the end user. Then, display a message that includes your name and a brief description of what your program will do. Include instructions for the game. All input and output should be completed via the console. Permit the end user to play your game. You should determine if the player won a single game, including the determination of winning after the starting roll. Allow the user to play the game again after either winning or losing the first game. o Within your logic, call a static method you create in your .java file underneath of the main() method, named "roll()" that rolls the dice you need to roll. The roll() method could have at least one argument associated with it. The method should be a value returning method that returns the value of the die/dice to main(). You can roll all the dice at once, or one die at a time. While the game runs, you should have your program display via console prints the the value of each new roll and the goal number s/he is trying to roll again in order to win. The program should also specify if the end user wins or loses, whenever either occurs. The end user should be prompted to continue / roll the dice after each dice roll (when applicable). 2. Create a Die (single dice) class. This class will be instantiated as a Die object in the main() method of your program four times to represent four dice, which plays the game. In your class definition, create: o int value (to represent the current value of the Die) o a constructor method (called to create a Die in main()) o a roll() method, which is a mutator method that changes the value of the Die o Hint: You can use the static roll() method from activity 2 as a starting point to create this Die class method o You wouldn't use the static activity 2 roll() method anymore in main() -- but don't delete it's definition, keep the activity 2 static method roll() in your source code. o a getValue() method, which is an accessor method, that returns the value of the Die to main() Using this Die class that you define, instantiate it four times by creating four Die objects in your main() method for game execution. Use the accessor andmutator methods as appropriate in main().

Provide a functionality that allows the computer to play on its own without user prompting. The user inputs a number that is the number of times the computer should play the game on its own, and when s/he pushes the button, the computer plays the game that many times. After playing, the computer should output the final results of all of the games. You can also output the win or loss after each game - your choice. After being displayed the welcome message from activity 2, display instructions to the end user as to enter a "1" or a "2." The user can enter "1" to play the game manually, or enter "2" to have the computer play on its own. If the user inputs "1" the manual, single should execute. If the user inputs "2" the user inputs a number that is the number of times the computer should play the game on its own, and then the computers plays the game that many times - outputting the results of each game and a tally at the end of the number of total wins and the number of total losses. The game should, in either mode, allow the end user to play again. o You can add any additional static methods you like to better organize your source code.

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

Students also viewed these Databases questions