/**
 * CS149 - Programming Fundamentals
 * Department of Computer Science
 * James Madison University
 * @version Fall 2019
 */

PA #1 - Chuck-a-luck

Introduction

Chuck-a-luck is a betting game played with three dice. The player puts his or her money down on one of the possible bets, then the dealer rolls the dice. The player collects a payout if the outcome matches the bet. A playable online version for understanding the problem is located here: http://the-chaos.com/cgi-bin/chuck-a-luck.cgi

The following table describes the possible bets:

Type Bet Odds
Single A specific number will appear on at least one die 1 dice, 1 to 1
2 dice, 2 to 1
3 dice, 10 to 1
Any Triple Any of the triples (all three dice show the same number) will appear 30 to 1
Big The total score will be 11 or higher with the exception of a triple 1 to 1
Small The total score will be 10 or lower with the exception of a triple 1 to 1
Field The total score will be outside the range of 8 to 12 (inclusive) 1 to 1

The final column in the table describes the payout if the player wins the corresponding bet. For example, if a player puts $5 down on single 3, and the roll is [3, 3, 2], the payout will be $10 because the odds for that outcome are 2 to 1. If the dice rolled are [3, 3, 3], then the payout will be $50, because the odds for that outcome are 10 to 1.

Your goal for this assignment is to develop and test a method for determining payouts in Chuck-a-luck.

Provided Code

Start with the following source files:

Dice.java

The Dice class represents a complete set of three rolled dice. Dice objects provide several methods:

Here is a code snippet that illustrates these methods:

Dice dice = new Dice(4, 2, 4); // Create a set of dice with 4, 2, and 4 showing

System.out.println(dice.getFirst());     // 4 will be printed

System.out.println(dice.getSecond());    // 2 will be printed

System.out.println(dice.getThird());     // 4 will be printed

System.out.println(dice.addValues());    // 10 will be printed (10 = 4 + 2 + 4)

System.out.println(dice.countValues(1)); // 0 will be printed. (zero 1's) 

System.out.println(dice.countValues(4)); // 2 will be printed. (two 4's) 

Driver.java

The file Driver.java contains the implementation of a simple terminal-based Chuck-a-luck game. This code includes all of the game logic except the payout method. Once you have completed ChuckALuck.java you can use this driver to try out your code.

Since this driver generates random dice rolls, it will not be very useful for systematically testing your solution. The main mechanism for running your code for this project will be the ChuckALuckTest.java file described below.

ChuckALuck.java

Your main task for this assignment is to implement the ChuckALuck.calculatePayout method according to the provided documentation string. For full credit, your finished method must satisfy the following requirements:

ChuckALuckTest.java

You must write JUnit tests for ChuckALuck.java. Rather than writing one very long testCalculatePayout method, you should write several smaller methods to handle distinct cases. The provided file contains some testing methods to get you started.

Notice that the names of these methods describe the situations they are designed to test:

testCalculatePayoutSingleNoMatch

You should properly document your tests and your ChuckALuck.java file.

Autolab will automatically evaluate your JUnit tests on the basis of statement coverage: Your tests must be written so that every line of code in ChuckALuck.java is executed during at least one test.

Categories you should test include(this is a template for your ChuckALuckTest.java file):

Part A - Readiness Quiz

Before the deadline for Part A you should read this document carefully, then look at the starter code provided above. Once you have a clear understanding of the expectations for this assignment, complete the readiness quiz in Canvas. The grading for this quiz will be all or nothing: your score on the quiz will be 0 if you miss any questions. If you do not successfully complete Part A, you cannot receive any credit for Parts B and C. Take this test early so you can get help if you need it.

Part B - Test Submission

Submit your finished version of ChuckALuckTest.java. Autolab will evaluate your tests by running them against a hidden reference solution.

Note that this project is an example of test-driven development. You will develop your tests before you write the code that is being tested.

Part C - Code Submission

Once you have finished ChuckALuck.java, upload a .zip file containing both ChuckALuck.java and ChuckALuckTest.java. You should not include Driver.java or Dice.java in your submission.

Before uploading your submission to autolab.cs.jmu.edu, be sure to complete the following steps:

Your submission will be graded using the following criteria:

Points
Part A Quiz 10
Part B Tests 20
Part C Autolab Score 30
Part C Code Quality 10

The Autolab grading for part C will be based both on the correctness of ChuckALuck.java and on the quality of the tests in ChuckALuckTest.java. Autolab will test each of the following:

Honor Code

This assignment must be completed individually. Your submission must conform to the JMU Honor Code. Authorized help is limited to general discussion on Piazza, the lab assistants assigned to CS 149, and the instructor. Copying work from another student or the Internet is an honor code violation and will be grounds for a reduced or failing grade in the course.