Assignments will gradually begin to involve larger and larger programs, made up of multiple classes. Think carefully about the design of your program, its classes and methods. Also, do not forget to keep on commenting your code and using good method decomposition and design in your homeworks.
In this HW, you will create a slot machine or one-armed bandit simulation. A slot machine is a gambling machine commonly found in Las Vegas, but here we will just be building one for fun. A slot machine consists of three spinning circular drums which each have many different symbols around them. The user pulls down a handle and the drums start spinning. They each then stop randomly on a symbol and if certain combinations of symbols come up, then the player wins. Just think of it like 3 random number generators.
In our game, each of the three positions have four different symbols: bell, grape, cherry and a dash or line. Each drum has one of the bell, grape, and cherry, and five of the lines. Thus, each of the eight different possibilities (bell, grape, cherry, line, line, line, line, line) should come up with equal probability on each spin. The user can bet round dollar amounts of one dollar or more. The machine pays out combinations as shown below (multiples of the bet amount).
| Combo | Payoff | ||
| Bell | Bell | Bell | 10 |
| Grape | Grape | Grape | 7 |
| Cherry | Cherry | Cherry | 5 |
| Cherry | Cherry | ****** | 3 |
| Cherry | ****** | Cherry | 3 |
| ****** | Cherry | Cherry | 3 |
| Cherry | ****** | ****** | 1 |
| ****** | Cherry | ****** | 1 |
| ****** | ****** | Cherry | 1 |
The ****** can be any character including the lines.
You should implement a GUI application that has a cell for each of the 3 random symbols coming up and a button which starts a "spin". The interface should display the user's current money holdings (starts at $100). It also should have a text field where the user can enter his or her bet with a minimum bet of $1 (default) and a max up to the person's present holding.
Your application should also have a set of two radio buttons: Regular and Test. When the slot machine is in regular mode, the game should play as described above. When it is in Test mode, no Line symbols should ever come up on any of the drums. (The Bell, Grape, and Cherry should have equal likelihood of coming up.) This will allow us to test your game with more chances of winning combinations coming up.
The normal flow is for the user to enter a bet by typing it in (or just using the default $1) and then pressing the spin button. The three windows on the drums then should show the random symbols that come up. From there, the program calculates the person's winnings (if any) and updates the current money holdings.
Since we just learned layout managers, you should try to make your user interface be as functional and look as good as possible. Do a nice layout of the individual components. Feel free to embellish. For instance, go out and find an image file for the different symbols to use in your interface (remember that labels can take images).
After you have finished your program, turn the files in via Webwork You will be submitting multiple files. Please make sure they are named as shown below: