Now, we are not advocating gambling in any way...
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 possible 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).
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. You can save the money as an int and assume the user will enter an int, but you still need to check that the bet is greater than the minimum $1 and less than or equal to the current money holdings. If the bet is invalid, give some kind of informative message to the user (for example, use JOptionPane and pop up a message box or have a label with a status message on your slot machine GUI, just make sure it's clearly visible).
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 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. If the user runs out of money (less than the minimum $1), pop up a message box or otherwise show a message informing the user.
You should also provide a Reset button that will reset the user's current holdings back to the original $100. Since we don't want to reset the winnings by accident, clicking the button should first pop up a confirmation prompt and should only reset the money if the user clicks OK or Yes.
Use layout managers and try to make your user interface be as functional and look as good as possible, even when the panel is resized. 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).Tips:
After you have finished your program, turn the files in via T-Square. You will be submitting multiple files. Please make sure they are named as shown below: