Due Date: Early bonus: Monday, September 16, midnight
Final Due Date: Friday, September 20, midnight
table of contents
You should create a directory cps100e in which all work for this class will be done (see the first lab for an explanation of how to do this). Each assignment should be done in its own subdirectory, for this assignment create a directory firstprog. All work for your assignment will then be done in the directory ~/cps100e/firstprog. You should change the acl (access control list) on your cps100e directory to give the professors, TAs, and UTAs permission to read your files, this was described in the first lab:
fs setacl cps100e ola:cps100e read
Change acl permissions before creating the firstprog subdirectory, or you'll
need to change the acl on the subdirectory too.
You will write programs to simulate the games of craps and roulette as desribed in A Computer Science Tapestry, pages 219-221, exercises 5.16 and 5.17. The explanations from the book are reproduced below.
prompt> playgame place your bet for this round enter wager between 0 and 500: 100 rolling ... 6 5 natural winner!! you have $600 do you want to continue [yes/no]?: yes place your bet for this round enter wager between 0 and 600: 200 rolling ... 5 1 rolling ... 4 5 rolling ... 6 4 rolling ... 5 4 rolling ... 5 2 loser, lost going for 6 you have $400 do you want to continue [yes/no]?: yes place your bet for this round enter wager between 0 and 400: 400 rolling ... 6 4 rolling ... 1 2 rolling ... 3 4 loser, lost going for 10 you're busted, game's overAs a start, you can implement the class Game and use the function main() shown below. This code is stored in craps.cc.
Write a program similar to the craps-playing program, but simulate a roulette game rather than a craps game. In roulette you can place bets on which of 38 numbers is chosen when a ball falls into a numbered-slot. The numbers range from 1--36 with special 0 and 00 slots. The 0 and 00 slots are colored green; each of the numbers 1--36 is red or black. The red numbers are 1, 3, 5, 7, 9, 12, 14, 16, 18, 19, 21, 23, 25, 27, 30, 32, 34, and 36. Gamblers can make several different kinds of bet, each of which pays off at different odds.
| bet | odds |
| red/black | 1 to 1 |
| odd/even | 1 to 1 |
| single number | 35 to 1 |
| two consecutive numbers | 17 to 1 |
| three consecutive numbers | 11 to 1 |
A payoff of 1 to 1 means that a $10.00 earns $10.00 (plus the bet $10.00 back); 17 to 1 means that a $10.00 earns $170.00 (plus the $10.00 back). If the wheel spins 0 or 00 then all bets lose except for a bet on the single number 0/00 or on the two consecutive numbers 0/00.
You may find it useful to implement a separate Bet class to keep track of the different kinds of bets and odds. For example, when betting on a number you'll need to keep track of the number while betting on red/black requires only that you remember the color chosen.
You should use a class similar to the Game class from the craps program, but modified to play roulette.
Adding bells and whistles to the program can earn extra points.
To submit your assignment, type: