Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java Edit: When the user enters -1 it means they want to keep their remaining dice and use it as their final dice. For

In Java

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Edit: When the user enters -1 it means they want to keep their remaining dice and use it as their final dice.

For this lab you will write a Java program that plays the game Poker Dice. In this game, five dice are rolled and scored as if they were a hand of playing cards. The game goes through two separate phases. Ir the tirst phase, a "hand" of dice is presented to the player. The player then selects which dice he wants to keep and which he wants to re roll. Once that decision is tinished, all of the dice that the player has marked to re-roll are re-rolled and the tinal "hand" ot dice is displayed. The hand should then be scored according to the rules ot Poker Dice (given helow) and the result displayed on the screen. Scoring Poker Dice The tollowing table shows the values of different Poker Dice hands in order (i.e. Five of a Kind beats Four of a Kind, Four of a Kind beats Full House, etc.): Hand Descrintion Fxamples Five ot a Kind All tive dice show the same value [5, 5, 5, 5, 5] Four of a Kind Full House Three of a Kind Four of the five dice show the same value [4, 4, 4, 3, 4] I1, 2, 2, 1, 1 3, 3, 3, 5, 5] Three of the five dice show the same value, the other two show a different matched value Three of the five dice show the same value, the other two show different values 3, 3, 3, 2, 5] [2, 3, 1, 5, 41 ht Two Pair One Pair Highest Card X If none of the above hands exist, then the score for the hand is "Highest Card X" where X is the highest value in the list i five dice together show a sequence of values 1-5 or 2-6 or 3-7 etc. Two of the flve dice show the same value, and two other dice show a different shared value Iwo of the fve dice show the same valuc, the other dice show different values 3, 2, 4, 5 1, 2, 2, 1, 3] 3, 5, 6, 3, 6 3, 5, 6, 3, 1 [1, 2, 3, 5, 7] - Highest Card7 2, B, 4, 51 Highest Card B Note that for scoring, only the highest score is reported. So a hand like [5, 5, 5, 5, 5] should only be reported as "Five of a Kind" even though it also fits the definition of "Four of a Kind" and "Two Pair" etc. The idea behind scoring is that the hand is scored with only the best possible result, and scores are showed in descending order in the table above In this assignment you are required to implement a scoring function that scores all of the above hands EXCEPT for the Straight. Your code must correctly score 5 of a kind, 4 of a kind, full house, three of kind, two pair, one pair, and highest card X "hands" of dice. For up to 2 points of extra credit, you may add the ability to score Straights to your scoring functio Indicate in the comnents of your code that your code scores Straights as well as the other hands. For this assignment you must start with the following "skeleton" of Java code. Import this into your Eclipse workspace and fill in the methods as directed. For this assignment you WILL want to add extra methods beyond the methods defined in the skeleton. Feel free to add any methods you find useful, but make sure that you add comments indicating what they do following the form of the rest of the comments in the code Project10.java NOTE: To generate a randorm number between 1 and 10, use the Math.random function as previously used in lab assignments. In this case, a random roll between 1 and 10 would be produced by this snippet of code int rallntdon() 10)+1

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

Database Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions