CSCI 261 - Programming Concepts (C++)Fall 2016 - Assignment 05 - Solo YahtzeeQuick Links: Blackboard | EECS | Mines | Piazza | zyBooks |
|||||||||
| Home | Contact | Syllabus | Assignments | Schedule | Resources | | |||||||||
This assignment is due by September 28, 2016 08:00am.
This assignment exercises your ability to use functions in conjunction with everything else we learned to this point. You will make a very very simple Yahtzee game. (Don't worry. We will revisit this again later on and beef it up to make it 2 player).
As you progress through the assignment and are creating new functions, be sure to test that the function is doing what you expect it to. In Test-Driven Development (TDD), you would create your function header and an empty function body. Then you would write a test that would pass if the function was working - but we know it will initially fail, the function does nothing! Now go back and implement the function. You know your function is working when your test passes. In reality, we probably want to be writing several tests for a single function that are testing potential error points as well as proper operation. The potential error points will come from looking at our boundary conditions and edge cases. What is the range of expected input? Write tests to check the function output when our input is within this range, equal to the extreme of our range, outside our range, and any other special condition scenarios. Rolling the Dice
A key part of playing Yahtzee is the joy of shaking the dice, rolling them on the table, and listening to them rattle. While we can't simulate this joy virtually (yet! we will eventually add graphics and you can explore audio later on), we still need to mimic the randomness of rolling the dice. This should be a giant red flag to you that you will need to use your friend rand(). You will need to write two functions to accomplish rolling the dice.
The first function should be called RollDie (singular). This function takes nothing as input. The function returns an integer. This function should return a random value between 1 and 6 inclusive simulating rolling a single die. The second function should now be called RollDice (plural). This function will take five integer parameters passed by reference and five boolean parameters passed by value for a total of 10 parameters. The function returns nothing. The five integer parameters correspond to our five dice. The five boolean parameters are flags indicating which dice are being "held" and therefore should NOT be rolled. Each of the five booleans corresponds to an individual die. The function should then use your RollDie function to roll only the dice that are not being held as indicated by the boolean flags. Printing the Scorecard
When the player rolls the dice, we need to inform the player what the results of their dice are. We will accomplish this by printing out the score card showing all previously earned points and points to be earned from this roll. We will use another function to accomplish this task.
The function name is simply PrintScorecard. The function will take eighteen (18!) integers are input - ALL passed by value. The function returns nothing. The first five parameters correspond to our five rolled dice. The next thirteen parameters are the individual scores for each scenario. We need to pass in the results of our previous rounds to update our grand totals. This means we'll need to be keeping track of each scenario's score in our main function. The function should now print a table listing each scenario and either the points earned in a previous round OR the points to be earned based on the current roll. We recommend setting each scenario score equal to some special value that indicates the scenario has not yet been scored. (Hint: zero is not a good choice) It is up to you how to best format the table, one such example is below. In this example, right aligned numbers are previously scored and left aligned numbers are the current roll. Playing the Game!
We now have everything ready to play the game! You will need to implement the following pseudocode to create your game:
Roll #2 You rolled: 6 3 1 4 5 |-------------------|--------| | Scenario | Score | |-------------------|--------| | (1) Ones | 1 | | (2) Twos | 8 | | (3) Threes | 3 | | (4) Fours | 12 | | (5) Fives | 20 | | (6) Sixes | 6 | |-------------------|--------| | Upper Total | 46 | | Bonus | 0 | |-------------------|--------| | (7) Three Kind | 21 | | (8) Four Kind | 0 | | (9) Full House | 0 | | (a) S Straight | 30 | | (b) L Straight | 40 | | (c) Yahtzee | 0 | | (d) Chance | 17 | |-------------------|--------| | Lower Total | 108 | |-------------------|--------| | Grand Total | 154 | |-------------------|--------| Do you want to hold die 1? Y Do you want to hold die 2? Y Do you want to hold die 3? N Do you want to hold die 4? Y Do you want to hold die 5? Y Roll #3 You rolled: 6 3 3 4 5 |-------------------|--------| | Category | Score | |-------------------|--------| | (1) Ones | 0 | | (2) Twos | 8 | | (3) Threes | 6 | | (4) Fours | 12 | | (5) Fives | 20 | | (6) Sixes | 6 | |-------------------|--------| | Upper Total | 46 | | Bonus | 0 | |-------------------|--------| | (7) Three Kind | 21 | | (8) Four Kind | 0 | | (9) Full House | 0 | | (a) S Straight | 30 | | (b) L Straight | 40 | | (c) Yahtzee | 0 | | (d) Chance | 17 | |-------------------|--------| | Lower Total | 108 | |-------------------|--------| | Grand Total | 154 | |-------------------|--------| Select which category to score: a Roll #1 You rolled: 3 6 2 2 5
It is up to you if you want to implement the Bonuses for the Upper Total and multiple Yahtzees. Neither are required but will round out your game like it is actually played.
Functional Requirements
Hints
Grading Rubric
Your submission will be graded according to the following rubric.
SubmissionAlways, 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.
In summary, for homework due on Wednesday, September 28 follow these specific steps:
This assignment is due by September 28, 2016 08:00am.
| |||||||||
Last Updated: 01/01/70 00:00
|