Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Creat a simple Java console Yhatzee program. Requirements -5 x 3 array and set it with empty values, in this case 0//It will also initialize

Creat a simple Java console Yhatzee program.

Requirements

-5 x 3 array and set it with empty values, in this case 0//It will also initialize a value to track the score for the game and how many rounds have been played}

Main

- yahtzee game and then call the menu.

Menu -The menu will prompt the user if they want to play the game or not. At the completionwill ask if they want to play another round.

Start Game -This function will reset the score to zero, the number of rounds played to 0 and begin iterating through the rounds until the playRound function returns false;

Clear Array -At the end of each round you will want to set the values in the array back to 0. Roll

-Generate X random numbers (0 to 5 numbers) with a value range of 1 to 6 and place them in the last slots of the array. X will be determined by how many numbers were held in the preceding roll. If everything was held, no numbers will be generated or if no values were held, then you generate an entirely new set of numbers).

-Note we are using the last slots of the array because our hold will place numbers up front first, so we start inserting after the slots we know are held. This function needs to be aware of what set of rolls it is on, if its the second roll, it needs to place values in the second row. Hold

-This will create a loop asking the user for which values to hold. It will only accept numbers 1 to 5 or the letter q. Once q is selected it will copy the selected values to the next row in the array it will place them sequentially in the slots starting at 0 Then it will return a value for the number of values held.

Play Round -This function will be called at the start of each round. It will start by clearnig the array of current values. Then it will let the user roll 3 times and hold after the first 2 rolls. What is left after the final roll is what the user is scored on. At the end of the round it will increment the round counter by 1. If 10 rounds have been completed, it will return falseotherwise it will return true.

Score Hand -we will allow the program to choose the best score and regardless of whether the user has scored it before, allow that score. Note these scores are simplified for this program.

3 of a kind Sum of all the dice + 5 4 of a kind Sum of all the dice + 10 full house (2 matching dice and 3 matching dice) 25 pts small straight (4 dice in consecutive sequence) 30 pts large straight (all dice in consecutive sequence) 40 pts Yahtzee (all dice match) 50 pts Chance (anything) Sum of all the dice

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

Sybase Database Administrators Handbook

Authors: Brian Hitchcock

1st Edition

0133574776, 978-0133574777

More Books

Students also viewed these Databases questions