CSCI 261 - Programming Concepts - Summer 2019

Lab 5A - Yahtzee Functions

This lab is due by Friday, May 31, 2019 11:59 PM.
As with all labs you may, and are encouraged, to pair program a solution to this lab.


Yahtzee!



For this lab, we are going to collectively implement most of a Yahtzee game. Everyone will make a small piece of the game and we could then put all the pieces together to make a fully functioning game.

The first step to make Yahtzee is to know how to play. Here are the official rules. With a partner, get a bag of dice and play a game. Use this excel score sheet to keep score while you are playing. Be sure to take note of two pieces of information each round:
  1. What conditions must be satisified to earn points
  2. How many points are scored for each category
Play through a complete game. Who won?

After you've played at least one complete game, take a look at the bag the dice came in. You should see a scoring category written on the outside. You will need to write two functions for this category.
  1. The first function will test the given five dice for whether the conditions of the Yahtzee category are met or not. We will represent each of our dice with an integer variable. Therefore, the function should accept as input five integers to represent our five dice. The function should return as output true if the conditions are met and false otherwise. Name the function isXYZ where XYZ is the name of the category you are testing for in proper camel case.
  2. The second function returns the score if the current set of dice were going to be scored for that category. The function should accept as input five integers to represent our five dice. The function should return as output the score for the category. Name the function scoreXYZ where XYZ is the name of the category you are testing for in proper camel case. Recall for scoring some categories, a score should only be returned if the condition is present. If the dice do not satisfy the conditions, then zero is returned as the score.

For example, the two functions for the Full House category would be structured as follows:

bool isFullHouse( int die1, int die2, int die3, int die4, int die5 ) {
  // code goes here
}

int scoreFullHouse( int die1, int die2, int die3, int die4, int die5 ) {
  // code goes here
}

To test that our functions are correct and can handle a variety of scenarios, we are going to use the AutoGrader to test our functions. Note you must be connected to the Mines network in order to access the AutoGrader website (this means you need to use the VPN if off campus).

Once logged in, choose "CSCI 261 Programming Concepts" and this lab. You will now see a list of all the functions possible for this lab. Begin by selecting your isXYZ() function.

You'll now see a brief problem statement along the left and an editor on the right. Go ahead and click the "Test" button on the bottom left. You'll see a bar appear saying "Running Tests" and then the bar will turn red with a green box. Each of these boxes represent a different test case. By hovering over a single box, you can see the input provided for that test and what the expected output is. Hover over the green box and you'll see:

Passed Test
Input: { 1, 1, 1, 2, 2 }
Output: 1

Now go one box to the right and hover over the red box. This time you'll see:

Failed Test
Input: { 2, 1, 4, 5, 1 }
Expected Output: 0
Your Output: true

Your goal is get all the boxes to be green. Use the editor to complete the function body. When you make an edit, click "Test" again to see if any additional tests have passed. Two very important pieces of information:
  1. Be sure to click "Save" button often on the editor toolbar. If you leave the webpage, then your code will be lost.
  2. When you are happy with your function, click the "Submit" button on the bottom left to complete the tests.
Once you have finished with the isXYZ() function, now complete the corresponding scoreXYZ() function. If you need to use your isXYZ() function within scoreXYZ(), then you can copy and paste it above line 1.

When all the tests pass for the score function and you've submitted both functions, then you are done with this lab! Read below about how to properly receive credit for this lab.


What To Turn In - Part I



On Piazza, there are pinned posts at the top of the feed relating to each category. Once all the tests are passed, post your two functions as a reply to the corresponding post. The assignment will require each student to have all of the functions to implement a full fledged yahtzee game.


What To Turn In - Part II



Back in CLion land, create a file called main.cpp for a Lab5A project. Inside this main, copy your two functions from the AutoGrader and paste them into this file. We do not need a main() function and full program for this lab - just the two functions. Be sure to include your partner's name in the header of the file. Also be sure that you have pressed Submit and Save in the AutoGrader with all tests successfully passing.



Lab Submission



You will submit your solution to this lab with the rest of Set5. Detailed instructions for doing this are posted in Assignment 5.


This lab is due by Friday, May 31, 2019 11:59 PM.
As with all labs you may, and are encouraged, to pair program a solution to this lab.