Question: USE JAVA PLEASE The game of Pig is a simple two-player dice game in which the first player to reach 100 or more points wins.

USE JAVA PLEASE The game of Pig is a simple two-player dicegame in which the first player to reach 100 or more pointsUSE JAVA PLEASE

The game of Pig is a simple two-player dice game in which the first player to reach 100 or more points wins. Players take turns. On each turn, a player rolls a six-sided die: If the player rolls a 1, then the player gets no new points and it becomes the other player's turn. If the player rolls 2 through 6, then he or she can either O ROLL AGAIN or HOLD. At this point, the sum of all rolls is added to the player's score and it becomes the other player's turn. Part 1: The Die class Implement an object class Die that represents a die of any number of sides: Die -numberOfSides: int +Die (numberOfSides:int) +Die () +roll(): int As shown in the UML diagram above, the Die class has two constructors; the no-argument constructor sets the numberOfSides instance variable to 6. Part 2: The Game of Pig Write a program (as a second object class with a main method) that uses an object of the Die class from Part 1 of this assignment to play the game of Pig, where one player is a human and the other is the computer. When it is the human's turn, the program should show the score of both players and the previous roll. Allow the human to input "r" to roll again or "h" to hold. The computer program should play according to the following rule: Keep rolling when it is the computer's turn until it has accumulated 20 or more points, then hold. If the computer wins or rolls a 1, then the turn ends immediately. Allow the human to roll first. Note: your game must use the Die class, or no points will be given for this assignment

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!