Question: a. You created a Die application that randomly throws five dice for the computer and five dice for the player. The application displays the values.

a. You created a Die application that randomly €œthrows€ five dice for the computer and five dice for the player. The application displays the values. Modify the application to decide the winner based on the following hierarchy of Die values. Any higher combination beats a lower one€”for example, five of a kind beats four of a kind.
  • Five of a kind
  • Four of a kind
  • Three of a kind
  • A pair

For this game, the dice values do not count; for example, if both players have three of a kind, it€™s a tie, no matter what the values of the three dice are. Additionally, the game does not recognize other poker hand type combinations such as a full house (three of a kind plus two of a kind) or a straight (sequential values). Figure 8-21 shows a sample execution. Save the application as FiveDice2.java.

Computer rolled: 1 4 3 4 4 You rolled: 6 4 2 3 4 Computer has 3 of a kind You have 2 of a kind Computer wins

b. Improve the FiveDice2 game so that when both players have the same combination of dice, the higher value wins. For example, two 6s beats two 5s. Save the application as FiveDice3.java.

Computer rolled: 1 4 3 4 4 You rolled: 6 4 2 3 4 Computer has 3 of a kind You have 2 of a kind Computer wins

Step by Step Solution

3.34 Rating (160 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a public class Die private int value private static final int HIGHESTDIEVALUE 6 private static final int LOWESTDIEVALUE 1 public Die value intMathrandom 100 HIGHESTDIEVALUE LOWESTDIEVALUE public int g... View full answer

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 Java Programming Questions!