For this lab, you will write a small simulator on the simplest version of the dice game called Craps: http://casinogambling.about.com/od/craps/a/craps101.htm
Specifically, you will implement the Passline Bet version of craps. Using two sixsided 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.
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 users 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: Mustafa
Hello Mustafa!
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: 10000
The username can be any String (even an empty one). 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 users balance. You must also check and make sure that the bet amount throughout the simulation never exceeds the users 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 users 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:
‐ played
‐ won
‐ Number of games lost
‐ Maximum number of rolls in a single game
‐ “Natural” roll count
‐ “Craps” roll count
‐ winning streak
‐ losing streak
‐ Maximum balance throughout simulation
‐ The game number when the Maximum balance was obtained
After the statistics are printed out, the program will prompt the user to run other simulation or not. If the user chooses not to, your program should terminate. If the user wants to run another, 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 (lowercase / uppercase responses are valid).
A sample output of what the statistics should look like starting at the last game in the simulation is:
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
There are many ways to structure / organize your code and I will provide some requirements for you to follow. Some objects to implement are:
Lab2.java
CrapsSimulation.java
A class representing all the information for the Simulation. This includes:
Public methods that this class must implement are:
CrapsGame.java
A class representing all the information for a single craps game. This includes:
Public methods that this class must implement are:
CrapsMetricsMonitor.java
A class representing all of the statistics gathered during a single simulation.
Public methods: