This assignment is due by Friday, May 31, 2019 11:59 PM.
As with all assignments, this must be an individual effort and cannot be pair programmed. Any debugging assistance must be provided in accordance with the course collaboration policy.
Do not forget to complete the following labs with this set: L5A,
L5B,
L5C
.
· Instructions · Rubric · Submission ·
Yahtzee!
- What conditions must be satisified to earn points
- How many points are scored for each category
Rolling the Dice
rollDie
that has no input and returns an int
as output. This function should generate
a random value between 1 and 6, inclusive. Once you've tested your function is working properly, move on to the next step.
int
. Therefore, to represent a hand
of dice, we will use five individual int
s. (Note: we are using five single integer variables and not an array because that
will match our function interface we created in Lab5A.)Once these dice are created, let's create a function called
printHand
that accepts the five integers as input and has no output.
This function should simply print out each value to the screen (see below). We'll now make a third function called
rollDice
that accepts the five integers as input all passed by reference and has no output.
The function should then call the rollDie
function and assign each die with a random value. At this point, your
program should have output similar to:
Your hand is: 4 1 2 5 6
Playing a Round
Your hand is: 1 6 2 1 5 2 rolls remaining. Do you want to roll again? (Y or N) Y Your hand is: 2 1 6 2 5 1 rolls remaining. Do you want to roll again? (Y or N) Y Your hand is: 6 4 3 1 4 0 rolls remaining.
Your hand is: 1 5 2 3 2 2 rolls remaining. Do you want to roll again? (Y or N) Y Your hand is: 4 4 4 6 6 1 rolls remaining. Do you want to roll again? (Y or N) N
bool
s. Asking the player which dice to keep is only the first part of this step. The second step is
to also pass these five boolean variables as additional parameters to the rollDice
function. We also need to modify
the body of the rollDice
function to only reroll the dice that the user chose not to keep. Now, our
game looks like below:
Your hand is: 2 2 5 1 3 2 rolls remaining. Do you want to roll again? (Y or N) Y Do you want to keep die #1? (Y or N) Y Do you want to keep die #2? (Y or N) Y Do you want to keep die #3? (Y or N) N Do you want to keep die #4? (Y or N) N Do you want to keep die #5? (Y or N) N Your hand is: 2 2 2 6 5 1 rolls remaining. Do you want to roll again? (Y or N) Y Do you want to keep die #1? (Y or N) Y Do you want to keep die #2? (Y or N) Y Do you want to keep die #3? (Y or N) N Do you want to keep die #4? (Y or N) N Do you want to keep die #5? (Y or N) Y Your hand is: 2 2 3 4 5 0 rolls remaining.
Checking for Conditions
Scenario | Description | Points |
Ones | Ones | Sum of Ones |
Twos | Twos | Sum of Twos |
Threes | Threes | Sum of Threes |
Fours | Fours | Sum of Fours |
Fives | Fives | Sum of Fives |
Sixes | Sixes | Sum of Sixes |
Three Of A Kind | Three dice of the same value | Sum of Dice |
Four Of A Kind | Four dice of the same value | Sum of Dice |
Full House | Two dice of one value and three dice of a different value | 25 |
Small Straight | Four dice in a row (1-4, 2-5, 3-6) | 30 |
Large Straight | Five dice in a row (1-5, 2-6) | 40 |
Yahtzee | Five dice of the same value | 50 |
Chance | Any combination of dice | Sum of Dice |
Which category do you want to score this hand as? ( 1) Ones ( 2) Twos ( 3) Threes ( 4) Fours ( 5) Fives ( 6) Sixes ( 7) Three of a Kind ( 8) Four of a Kind ( 9) Full House (10) Small Straight (11) Large Straight (12) Yahtzee! (13) Chance Category #:
Play the Game
- The user can play thirteen rounds - each consisting of rolling and choosing a category to score.
- We need to keep track of the player's total score across all rounds.
- The player cannot score the same category twice.
Your hand is: 4 5 3 1 2 2 rolls remaining. Do you want to roll again? (Y or N) N Which category do you want to score this hand as? ( 1) Ones ( 2) Twos ( 3) Threes ( 4) Fours ( 5) Fives ( 6) Sixes ( 7) Three of a Kind ( 8) Four of a Kind ( 9) Full House (10) Small Straight (11) Large Straight (12) Yahtzee! (13) Chance Category #: 11 Your current score is: 40 Your hand is: 2 1 2 4 1 2 rolls remaining. Do you want to roll again? (Y or N) Y Do you want to keep die #1? (Y or N) Y Do you want to keep die #2? (Y or N) Y Do you want to keep die #3? (Y or N) Y Do you want to keep die #4? (Y or N) N Do you want to keep die #5? (Y or N) Y Your hand is: 2 1 2 2 1 1 rolls remaining. Do you want to roll again? (Y or N) N Which category do you want to score this hand as? ( 1) Ones ( 2) Twos ( 3) Threes ( 4) Fours ( 5) Fives ( 6) Sixes ( 7) Three of a Kind ( 8) Four of a Kind ( 9) Full House (10) Small Straight (12) Yahtzee! (13) Chance Category #: 9 Your current score is: 65 Your hand is: 5 4 1 2 1 2 rolls remaining. Do you want to roll again? (Y or N) N Which category do you want to score this hand as? ( 1) Ones ( 2) Twos ( 3) Threes ( 4) Fours ( 5) Fives ( 6) Sixes ( 7) Three of a Kind ( 8) Four of a Kind (10) Small Straight (12) Yahtzee! (13) Chance Category #: 8 Your current score is: 65
Functional Requirements
- All functions must be placed in separate files. The function prototypes should be placed in to a
.h
file and the corresponding function definitions should be placed in to a.cpp
file. Specifically:- Place the function headers for rolling dice into a file named
dice.h
. - Place the function definitions for rolling dice into a file named
dice.cpp
. - Place the function headers for the 26 Yahtzee functions into a file named
yahtzee.h
. - Place the function definitions for the 26 Yahtzee functions into a file named
yahtzee.cpp
.
- Place the function headers for rolling dice into a file named
- Use const appropriately for parameters.
- Use pass-by-value and pass-by-reference appropriately for parameters.
Grading Rubric
Your submission will be graded according to the following rubric.
Points | Requirement Description |
6 | All labs completed and submitted L5A, L5B, L5C |
2 | User interaction matches examples above |
14 | Game is properly playable |
4 | Functional requirements above met. |
3 | (1) Comments used (2) Coding style followed (3) Appropriate variable names, constants, and data types used (4) Instructions followed |
29 | Total Points |
This assignment is due by Friday, May 31, 2019 11:59 PM.
As with all assignments, this must be an individual effort and cannot be pair programmed. Any debugging assistance must be provided in accordance with the course collaboration policy.
Do not forget to complete the following labs with this set: L5A,
L5B,
L5C
.
Submission
Always, always, ALWAYS update the header comments at the top of your main.cpp file. And if you ever get stuck, remember that there is LOTS of help available. The following instructions are copied from How to Submit Homework.
Submission Instructions
- File and folder names are extremely important in this process.
Please double-check carefully, to ensure things are named correctly.
- The top-level folder of your project must be named
Set5
- Inside
Set5
, create 4 sub-folders that are required for this Set. The name of each sub-folder is defined in that Set (e.g.L5A
,L5B
,L5C
, andA5
). - Copy your
main.cpp
, additional header & source files (dice.h, dice.cpp, yahtzee.h, yahtzee.cpp
) plus theCMakeLists.txt
file into the subdirectories ofSet5
(steps 1-2), zip thisSet5
folder (steps 3-4), and then submit the zipped file (steps 5-11) to Canvas. - For example, when you zip/submit
Set5
, there will be 4 sub-folders calledL5A
,L5B
,L5C
, andA5
inside theSet5
folder, and each of these sub-folders will have a file calledmain.cpp
, additional header & source files, plus the CMakeLists.txt file .
- The top-level folder of your project must be named
- Using Windows Explorer (not to be confused with Internet Explorer), find the file
named
"main.cpp"
located inside the folder for the particular lab or homework assignment you will submit.
STOP: Are you really sure you are viewing the correct assignment's folder?
- Now, for A5, right click on the
main.cpp
to copy the file. Then, return to theSet5/A5
folder and right click to paste the file. In other words, put a copy of your homework'smain.cpp
source code into theSet5/A5
folder. Repeat this for each additional header & source file you have with this assignment, plus CMakeLists.txt.
Follow the same steps for L5A, to put a copy of your lab'smain.cpp
into theSet5/L5A
folder. Repeat this process forSet5/L5B
,Set5/L5C
.
STOP: Are you sure yourSet5
folder now has all your code to submit?
- Now, right-click on the
"Set5"
folder.- In the pop-up menu that opens, move the mouse
"Send to..."
and expand the sub-menu. - In the sub-menu that opens, select
"Compressed (zipped) folder"
.
STOP: Are you really sure you are zipping aSet5
folder with sub-folders that each contain amain.cpp
file in it?
- In the pop-up menu that opens, move the mouse
- After the previous step, you should now see a
"Set5.zip"
file.
- Now visit the Canvas page for this course
and click the
"Assignments"
button in the sidebar.
- Find Set5, click on it, find the
"Submit Assignment"
area, and then click the"Choose File"
button.
- Find the
"Set5.zip"
file created earlier and click the"Open"
button.
STOP: Are you really sure you are selecting the right homework assignment? Are you double-sure?
- WAIT! There's one more super-important step. Click on the blue
"Submit Assignment"
button to submit your homework.
- No, really, make sure you click the
"Submit Assignment"
button to actually submit your homework. Clicking the"Choose File"
button in the previous step kind of makes it feel like you're done, but you must click the Submit button as well! And you must allow the file time to upload before you turn off your computer!
- Canvas should say "Submitted!". Click "Submission Details" and you can download the zip file you just submitted. In other words, verify you submitted what you think you submitted!
"Set5"
folder
and only the "Set5"
folder, this zip folder must have several sub-folders, you must name all these folders correctly, you must submit the correct zip file for this
homework, and you must click the "Submit Assignment"
button. Not doing these steps is like bringing your
homework to class but forgetting to hand it in. No concessions will be made for
incorrectly submitted work. If you incorrectly submit your homework, we will not be able to
give you full credit. And that makes us unhappy. This assignment is due by Friday, May 31, 2019 11:59 PM.
As with all assignments, this must be an individual effort and cannot be pair programmed. Any debugging assistance must be provided in accordance with the course collaboration policy.
Do not forget to complete the following labs with this set: L5A,
L5B,
L5C
.