Question: Create a Die class from which you can instantiate an object containing a random value from 1 through 6 . The constructor sets the value.

Create a Die class from which you can instantiate an object containing a random value from 1 through 6. The constructor sets the value. Include a method to return the value. Save the file as Die.java.
Use the Die class to create a simple dice game in which the user chooses a number between 2(the lowest total possible from two dice) and 12(the highest total possible). The user rolls two dice up to three times. If the number chosen by the user comes up, the user wins and the game ends. If the number does not come up within three rolls, the computer wins. Save the application as TwoDice3.java.
Using the Die class, create a version of the dice game Pig that a user can play against the computer. The object of the game is to be the first to score 100 points. The user and computer take turns rolling a pair of dice following these rules:
On a turn, each player rolls two dice. If no 1 appears, the dice values are added to a running total, and the player can choose whether to roll again or pass the turn to the other player.
If a 1 appears on one of the dice, nothing more is added to the players total, and it becomes the other players turn.
If a 1 appears on both of the dice, not only is the players turn over, but the players entire accumulated score is reset to 0.
In this version of the game, when the computer does not roll a 1 and can choose whether to roll again, generate a random value between 0 and 1. Have the computer continue to roll the dice when the value is 0.5 or more, and have the computer quit and pass the turn to the player when the value is not 0.5 or more.
Save the game as PigDiceGame.java.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!