Program #5 mplementing Yahtzee

$24.99 $18.99

Write a C++ program that plays the game of Yahtzee. Here are instructions for playing the game: http://www.hasbro.com/common/instruct/Yahtzee.pdf (http://www.hasbro.com/common/instruct/Yahtzee.pdf) You can also find online implementations if you want to see the game in action. One specific online implementation is at: https://cardgames.io/yahtzee/ (https://cardgames.io/yahtzee/) Your game will allow 1-2 players, and at the end, you need to…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Categorys:

Description

5/5 – (2 votes)

Write a C++ program that plays the game of Yahtzee. Here are instructions for playing the game:

http://www.hasbro.com/common/instruct/Yahtzee.pdf

(http://www.hasbro.com/common/instruct/Yahtzee.pdf)

You can also find online implementations if you want to see the game in action. One specific online implementation is at: https://cardgames.io/yahtzee/ (https://cardgames.io/yahtzee/)

Your game will allow 1-2 players, and at the end, you need to ask if the users want to play again. There are 5 six-sided dice in the game and you get three rolls to try to make something on the scoresheet. You must use an array to hold the values of the 5 dice and an array to hold the scores for the 16 categories for a player.

The top half of the scoresheet is only a sum of 1 or more of dice you are trying to get: 1s, 2s, 3s, 4s, 5s, and 6s, and if you score 63 or more points in this section, you get an additional 35 points.

The bottom half of the scoresheet consist of options that have pre-defined points or a total of all the dice. You have the options for a three of a kind (total of all dice, but has to have 3 or more of the same number), four of a kind (total of all dice, but has to have 4 or more of the same number), full house (25 pts, 2 dice the same and 3 dice the same), small straight (30 pts, 4 numbers in a row), large straight (40 pts, 5 numbers in

a row), Yahtzee (50 pts, 5 dice the same number), up to 3 bonus Yahtzees (100 pts each, 5 dice the same number), and chance (total of all dice, any combination).

After your first roll, a player can choose to roll 0-5 specific dice again. The player needs to state how many dice they want to re-roll and which ones they want to re-roll by providing the array indices for each die. If the player chooses not to roll again or has rolled 3 times, then the player must choose a category not previously chosen on the scoresheet. If the dice do not match the rules for that category, then the player takes a 0 for that category. Once a category has a score (even a zero score), it cannot be chosen again, so think carefully about what value you are going to use to initialize the scoresheet!!!

The bonus Yahtzee can only be chosen if there is a non-zero score in the Yahtzee!!! The player’s turn is over once a category is chosen, and the game is over once all players have put a score in all categories. The final score is a total points from the two sections, including the bonus if the top section is 63 or greater.

Command Line Arguments

To support various numbers of players, you will run the program with the specific number at runtime, rather than prompting for the input. The user can enter the number of players, 1-2.

1-player Example:

./yahtzee 1

Addi onal Requirements

In addition to the earlier specifications, your program must meet these requirements:

Print an error message and recover, when the player doesn’t supply a valid category. This includes selecting a category with a score, which can include a zero for the score. Make sure to carefully consider this when you are designing your program!

Update: as announced in class on Friday, you can safely assume that the TAs will only test your program with the command line values of “1” and “2” (unless you also did the extra credit). So you no longer have to halt your program if other input is provided.

Correctly determine the score for the category based on the dice (Remember, if the dice do not match the rules for the category, then a zero score is placed in that category). Play the game correctly based on rules and number of players.

Continue to play until the user selects no.

You must not have any global variables

You must use a dynamic 1-d array for the second player’s scoresheet, since there may or may not be a second player.

Your functions need to focus on performing a particular task. In other words, you need to use good modular design. If your function uses more than about 20 lines of code, this may be an indication that the code should be split into multiple functions. If the TA notices that your code is not sufficiently modular, you will lose points.

You must not have memory leaks.

Segmentation faults are not allowed (e.g. your program crashes).

(10 pts) Extra Credit – Suppor ng any number of players

Instead of having only 1-2 players, your Yahtzee will support any number of players using a dynamic 2-d array. This would have 16 rows/categories by N players.

(15 pts) Program Style/Comments

In your implementation, make sure that you include a program header in your program, in addition to proper indentation/spacing and other comments! Below is an example header to include. Make sure you review the

style guidelines for this class

(https://web.engr.oregonstate.edu/~goinsj/resources/general/cpp_style_guideline.pdf) , and try to follow them, i.e. don’t align everything on the left or put everything on one line!

/******************************************************

  • Program: yahtzee.cpp

  • Author: Your Name

  • Date: 11/7/2018

  • Description:

  • Input:

  • Output:

******************************************************/

Don’t forget that each of your functions needs to have a header. For example:

/******************************************************

  • Function:

  • Description:

  • Parameters:

  • Pre-Conditions:

  • Post-Conditions:

******************************************************/

Assignment Submission

Note that there are two deadlines for this assignment.

Your design document must be scanned and electronically submitted to Canvas (in the assignment tab) by Sunday, November 11th, 11:59pm. You may use one of the document scanners (available in KEC1130 and some other College of Engineering labs) to scan your paper design into a PDF document that can be submitted to Canvas.

Electronically submit your C++ source code to TEACH (https://engineering.oregonstate.edu/teach) by the

assignment due date on Sunday, November 18th, 11:59pm. Your TEACH submission should contain the

.cpp file with your source code.

Reminder

Every assignment in this course is graded by demoing your work for 10-15 minutes with a TA. You are required to meet with a TA within two weeks of the due date to demo. You can schedule a demo with a TA from the TA Office Hours tab in Canvas. The available times can be viewed in the far right column of the table (labeled “Grading Hours”). Click on one of the links to access the poll and insert your name in a specific time slot.

Demo Outside 2 Weeks: Assignments that are not demo’d within the acceptable time period will be subject to a 50 point deduction.

Demo Late Assignments: Late assignments must still be demoed within the two week demo period beginning from the assignment’s original due date.

Missing a Demo: If you miss your demo with a TA, you will receive a 10 point (one letter grade) deduction to that assignment for each demo missed.

Each program needs to be written according to the style guidelines

(https://web.engr.oregonstate.edu/~goinsj/resources/general/cpp_style_guideline.pdf) for this class. Remember that an important part of computer programming is making sure that your work is easily understandable by other programmers.

Program #5 mplementing Yahtzee
$24.99 $18.99