lab02 : Craps!

num ready? description assigned due
lab02 true Craps! Mon 04/15 08:00AM Sun 04/21 11:59PM

Goals

Rules

Specifically, you will implement the “Passline Bet” version of craps using two six-sided die. The rules are as follows:

“You place your bet on the passline before a new shooter begins his roll. This is known as the come out roll. If the shooter rolls a 7 or 11 you win. If the shooter rolls a 2, 3 or 12, you lose. If the shooter rolls any other number, that number becomes the point number. The shooter must roll that number again before a seven is rolled. If that happens, you win even money for your passline bet. If a seven is rolled before the point number is rolled again, you lose.”

When the user rolls a 7 or 11 on the first roll, this is known as “Natural.” When the user rolls a 2, 3, or 12 on the first roll, this is known as “Craps.”

Requirements

Your simulation will prompt the user for their name, the amount of money the user brings to the table, and the amount of money the user wants to bet. The simulation will continuously run by placing the bet amount continuously until the user’s balance is $0. A sample output (with some error cases) for this is as follows (bold text indicates user input):

Welcome to SimCraps! Enter your user name: Richert
Hello Richert!
Enter the amount of money you will bring to the table: 1000
Enter the bet amount between $1 and $1000: 1001
Invalid bet! Please enter a bet between $1 and $1000: -2
Invalid bet! Please enter a bet between $1 and $1000: 100

The username can be any String (even an empty one) without any whitespaces. You can assume that the user will only enter a valid Integer value for the initial balance brought to the table. However, your program must check that the bet amount is in a valid range between $1 and the user’s balance. You must also check and make sure that the bet amount throughout the simulation never exceeds the user’s remaining balance. For example, if the original bet was $100 and you only have a balance $50, then the bet for that game will be $50. If you win, and your balance is back up to $100, the next bet will be your original bet of $100.

During the games played in the simulation, you will need to print out the actions to the console (i.e. what the user is rolling, if the user won, if the user lost, what the user is betting, and what the user’s current balance is). A sample output for a few games of craps is as follows:

Richert bets $100
Rolled a 5
Rolled a 7
*****Crap out! You loose.*****
Richert's balance: 900. Playing a new game...
Richert bets $100
Rolled a 8
Rolled a 6
Rolled a 8
*****Rolled the point! You win!*****
Richert's balance: 1000. Playing a new game...
Richert bets $100
Rolled a 3
*****Craps! You loose.*****
Richert's balance: 900. Playing a new game...
Richert bets $100
Rolled a 7
*****Natural! You win!*****

Once the simulation is over, your program will print out statistics of the entire simulation. The stats you need to keep track of are:

After the statistics are printed out, the program will prompt the user to run another simulation or not by entering ‘y’ or ‘n’. If the user chooses not to, your program should terminate. If the user wants to run another simulation, then the simulation is rerun and starts by asking the user for their name, balance, and bet. Your program must check to see if the user input is valid (lower-case / upper-case responses are valid).

Richert's balance: 100. Playing a new game...
Richert bets $100
Rolled a 9
Rolled a 8
Rolled a 6
Rolled a 7
*****Crap out! You loose.*****
Richert's balance: $0

*****************************
*** SIMULATION STATISTICS ***
*****************************
Games played: 230
Games won: 110
Games lost: 120
Maximum Rolls in a single game: 29
Natural Count: 44
Craps Count: 25
Maximum Winning Streak: 9
Maximum Loosing Streak: 7
Maximum balance: 2100 during game 97

Replay? Enter 'y' or 'n': n

Structure

There are many ways to structure / organize your code and I will provide some requirements for you to follow. Some objects to implement are:

Lab02.java

CrapsSimulation.java

CrapsGame.java

CrapsMetricsMonitor.java

Submitting to Gradescope

The lab assignment “Lab02” should appear in your Gradescope dashboard in CMPSC 56. If you haven’t submitted anything for this assignment yet, Gradescope will prompt you to upload your files.

For this lab, you will need to upload your source files (CrapsGame.java, CrapsMetricsMonitor.java, CrapsSimulation.java, and Lab02.java). You either can navigate to your files, “drag-and-drop” them into the “Submit Programming Assignment” window, or use your private GitHub repo to submit your work.

If you already submitted something on Gradescope, it will take you to their “Autograder Results” page. There is a “Resubmit” button on the bottom right that will allow you to update the files for your submission.

Most of the programming assignments for this class will not be autograded in the same way you may have seen in earlier courses. We will use Gradescope mainly as a “dropbox” for all of your assignments. Our staff will manually grade your assignments and assign a score to your submission.

Since Gradescope autograding is disabled, it is very important for you to test and compile your code locally according to the specifications of this lab. As a software developer, it’s an important skill to think of correct functionality and test cases on your own. Be sure to do this before submitting your code to Gradescope. If our staff cannot run your code, then you will receive a 0 for this assignment (and this will not be apparent when submitting your code since Gradescope will not actually compile your code for this assignment).

Your submission will initially have a score of 0.0/100. Don’t worry - this is normal. Once the assignment has been graded by our staff, your actual score will be updated.