Reminder: Formatting is always important in your code (comments, indentation, variable names, etc.) And please always...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Reminder: Formatting is always important in your code (comments, indentation, variable names, etc.) And please always start your Java code file with a multi-line comment listing the name of the developer, the date of completion and a short description of the program. And you must document each method. 1 Yahtzee If you have never played Yahtzee before, you can go play now at: http://www.yahtzeeonline.org/ Yahtzee is a game where the objective is to score points by rolling five dice to make certain combinations. The dice can be rolled up to three times in a turn to try to make various scoring combinations. A game consists of thirteen rounds. In each round, a player gets three rolls of the dice, although they can choose to end their turn after one or two rolls. After the first roll the player can save any dice they want and re-roll the other dice. This procedure is repeated after the second roll. The player has complete choice as to which dice to roll. They could re-roll a die for the third roll that was not rolled on the second roll. The Yahtzee scorecard contains 13 different category boxes and in each round, after the third roll, the player must choose one of these categories. The score entered in the box depends on how well the five dice match the scoring rule for the category. Details of the scoring rules for each category are given below. As an example, one of the categories is called Three-of-a-Kind. The scoring rule for this category means that a player only scores if at least three of the five dice are the same value. The game is completed after 13 rounds are played, with each of the 13 boxes being filled. The total score is calculated by summing all thirteen boxes, together with any bonuses. The following table demonstrates the Yahtzee Scorecard Category What the dice must be Score Aces Any combo Twos Any combo Threes Fours Fives Sixes Any combo Any combo Any combo Any combo 3 of a kind 4 of a kind Full House Small Straight Large Straight Yahtzee Chance At least 3 dice the same At least 4 dice the same 3 of a kind + 2 of a kind Four sequential dice Sum of dice with value 1 Sum of dice with value 2 Sum of dice with value 3 Sum of dice with value 4 Sum of dice with value 5 Sum of dice with value 6 Sum of all 5 dice Sum of all 5 dice 25 Example Roll 1 1 1 34 scores 3 22256 scores 6 3 3 3 3 4 scores 12 4 4 5 5 5 scores 8 11225 scores 5 23666 scores 18 2 3 4 4 4 scores 17 4 5 5 5 5 scores 24 22 5 5 5 scores 25 30 1 3 4 5 6 scores 30 5 sequential dice All 5 dice the same 40 50 Any combo Sum of all 5 dice 1 2 3 4 5 scores 40. 22222 scores 50 113 55 scores 15 1.1 Sample Output See the Yahtzee.pdf document on brightspace for an example of sample output of this assignment 2 1.2 Game Setup [25 points] To design your program: 1. Inside the main method of your class, create two integer arrays, one of size five to represent the dice being rolled, and one of size 13 to represent the scorecard. 2. Write the method void rollDice (int[] diceArray) that sets each element in the dice array to be a random number between 1 and 6 inclusive. 3. Write the method void reroll (int[] diceArray) This method should first read the number of dice the user would like to reroll, then allow the user to specify the index(es) of which dice to reroll. Now we will need to create some methods to help us fill in the score card. 4. Write the method int sumAllDice (int[] dice) that sums up the total of all the dice currently in the array and returns the sum 5. Write the method int sumOf Dice (int[] dice, int faceValue) that sums up all of the dice that have a value of faceValue. So for example calling sumOf Dice (new int[] 1,2,3,3,1, 3) would return 6. 6. Write the method void scoreDice (int () scorecard, int () dice, int category) category represents the user's selection of which category they want to score the dice for (ex. three of a kind, small straight, etc.). The method should then store the correct total in the scorecard for the given state of the dice. Note that for some categories (Yahtzee, straight, etc.) your method should store a default value, for some categories (3 of a kind, chance, etc.) your method should store the sum of all the dice, and for others (aces, twos, etc.) your method should store the sum of some of the dice. 7. Write a method called int totalScore (int[] scoreCard) that sums up the total score of all the scores stored in the score card array. So far our program assumes the user will play the game properly and not try to cheat. Let's implement some methods to check and make sure the user isn't cheating! 8. Implement a method that checks to make sure that the user isn't trying to score a category in the score card that has already been scored (i.e., stop the user from scoring 3 of a kind more than once) 1.3 Main Method [10 points] Write the main method to allow the user to play a game of Yahtzee. The main program should allow the user to take 13 turns, and on each turn the following actions should happen: 1. roll all 5 dice 2. display the dice 3. allow the user to reroll any number of dice, no more than three times 4. allow the user to choose which item on the scorecard to fill 5. display the score card 6. When the last turn has finished, display the total sum of the scorecard. 3 Reminder: Formatting is always important in your code (comments, indentation, variable names, etc.) And please always start your Java code file with a multi-line comment listing the name of the developer, the date of completion and a short description of the program. And you must document each method. 1 Yahtzee If you have never played Yahtzee before, you can go play now at: http://www.yahtzeeonline.org/ Yahtzee is a game where the objective is to score points by rolling five dice to make certain combinations. The dice can be rolled up to three times in a turn to try to make various scoring combinations. A game consists of thirteen rounds. In each round, a player gets three rolls of the dice, although they can choose to end their turn after one or two rolls. After the first roll the player can save any dice they want and re-roll the other dice. This procedure is repeated after the second roll. The player has complete choice as to which dice to roll. They could re-roll a die for the third roll that was not rolled on the second roll. The Yahtzee scorecard contains 13 different category boxes and in each round, after the third roll, the player must choose one of these categories. The score entered in the box depends on how well the five dice match the scoring rule for the category. Details of the scoring rules for each category are given below. As an example, one of the categories is called Three-of-a-Kind. The scoring rule for this category means that a player only scores if at least three of the five dice are the same value. The game is completed after 13 rounds are played, with each of the 13 boxes being filled. The total score is calculated by summing all thirteen boxes, together with any bonuses. The following table demonstrates the Yahtzee Scorecard Category What the dice must be Score Aces Any combo Twos Any combo Threes Fours Fives Sixes Any combo Any combo Any combo Any combo 3 of a kind 4 of a kind Full House Small Straight Large Straight Yahtzee Chance At least 3 dice the same At least 4 dice the same 3 of a kind + 2 of a kind Four sequential dice Sum of dice with value 1 Sum of dice with value 2 Sum of dice with value 3 Sum of dice with value 4 Sum of dice with value 5 Sum of dice with value 6 Sum of all 5 dice Sum of all 5 dice 25 Example Roll 1 1 1 34 scores 3 22256 scores 6 3 3 3 3 4 scores 12 4 4 5 5 5 scores 8 11225 scores 5 23666 scores 18 2 3 4 4 4 scores 17 4 5 5 5 5 scores 24 22 5 5 5 scores 25 30 1 3 4 5 6 scores 30 5 sequential dice All 5 dice the same 40 50 Any combo Sum of all 5 dice 1 2 3 4 5 scores 40. 22222 scores 50 113 55 scores 15 1.1 Sample Output See the Yahtzee.pdf document on brightspace for an example of sample output of this assignment 2 1.2 Game Setup [25 points] To design your program: 1. Inside the main method of your class, create two integer arrays, one of size five to represent the dice being rolled, and one of size 13 to represent the scorecard. 2. Write the method void rollDice (int[] diceArray) that sets each element in the dice array to be a random number between 1 and 6 inclusive. 3. Write the method void reroll (int[] diceArray) This method should first read the number of dice the user would like to reroll, then allow the user to specify the index(es) of which dice to reroll. Now we will need to create some methods to help us fill in the score card. 4. Write the method int sumAllDice (int[] dice) that sums up the total of all the dice currently in the array and returns the sum 5. Write the method int sumOf Dice (int[] dice, int faceValue) that sums up all of the dice that have a value of faceValue. So for example calling sumOf Dice (new int[] 1,2,3,3,1, 3) would return 6. 6. Write the method void scoreDice (int () scorecard, int () dice, int category) category represents the user's selection of which category they want to score the dice for (ex. three of a kind, small straight, etc.). The method should then store the correct total in the scorecard for the given state of the dice. Note that for some categories (Yahtzee, straight, etc.) your method should store a default value, for some categories (3 of a kind, chance, etc.) your method should store the sum of all the dice, and for others (aces, twos, etc.) your method should store the sum of some of the dice. 7. Write a method called int totalScore (int[] scoreCard) that sums up the total score of all the scores stored in the score card array. So far our program assumes the user will play the game properly and not try to cheat. Let's implement some methods to check and make sure the user isn't cheating! 8. Implement a method that checks to make sure that the user isn't trying to score a category in the score card that has already been scored (i.e., stop the user from scoring 3 of a kind more than once) 1.3 Main Method [10 points] Write the main method to allow the user to play a game of Yahtzee. The main program should allow the user to take 13 turns, and on each turn the following actions should happen: 1. roll all 5 dice 2. display the dice 3. allow the user to reroll any number of dice, no more than three times 4. allow the user to choose which item on the scorecard to fill 5. display the score card 6. When the last turn has finished, display the total sum of the scorecard. 3
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these operating system questions
-
(Weighted average cost of capital) The target capital structure for Jowers Manufacturing is 50 percent common stock, 16 percent preferred stock, and 34 percent debt. If the cost of common equity for...
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
The following set of dotplots with overlaid boxplots gives the number of pairs of flip-flops students said they owned for 13 males (top) and 37 females (bottom) in a statistics class. The five-number...
-
Explain how a pension fund might use a long hedge with stock-index futures
-
What is the content of DTMs?
-
Using the C APM, what would the expected rate of return for a stock with a beta of 0.8 be when the risk-free rate is 3 percent and the expected return to the market is 9 percent? a. 7.8% b. 10.2% c....
-
The following 2013 information is available for Stewart Company: Condensed Income Statement for 2013 Sales..................................... $ 9,000 Cost of goods sold..................... (6,000)...
-
Normal Probability Distribution - Homew Question 13, O Points: 0 of 1 Assume that the heights of women are normally distributed with a mean of 63.6 inches and a standard deviation of 2.5 inches. If...
-
. 4. ABC partners whose capital balances amounted to P400,000 decided to admit D who invested P120,000 cash for a 20% interest the partners agreed to revalue the assets (1 Point) O asset...
-
What are some Latin American human rights abuses (such as Pinochet in Chile, the massacre of El Mozote, etc) that have contributed to Quijano's writing? How would Quijano respond to coloniality...
-
Sodaco runs a plant that makes and bottles private label soft drinks, sold directly to retailers. One client has recently placed an order for one of the SKU's with the following delivery schedule...
-
A Japanese company has a bond outstanding that sells for 91.53 percent of its 100,000 par value. The bond has a coupon rate of 3.4 percent paid annually and matures in 16 years. What is the yield to...
-
Community Catering (CC) began as a "meals on wheels" agency, providing dinners to elderly people and individuals who were permanently or temporarily homebound. Almost all of its clients were single...
-
Lopez Company is considering replacing one of its old manufacturing machines. The old machine has a book value of $47,000 and a remaining useful life of five years. It can be sold now for $57,000....
-
Consider that a router node in a wireless network of 100 nodes has received a valid packet that it needs to route. But the router has no knowledge of network topology and location of the destination...
-
What are the principal alloying elements in SAE 4340 steel?
-
Visit a Web site for currencies and make a list of currencies and rates of exchange with your own home currency.
-
Prepare a list of multinational firms that operate in your city. A good guide might be a firm that recruits on campus. Try to find their Web sites on the Internet and list where they have...
-
Visit a local supermarket and make a list of ten products manufactured outside your country.
Study smarter with the SolutionInn App