Repository navigation
Assignment 4 Wiki
Functions make it much easier to debug a program as well. You can call the function from the command line multiple times to make sure it functions correctly. Once you are satisfied you can all the function in your program and be confident that the results will be consistent. Slots In this program you are going to simulate a slot machine in Pierson Hall. The slot machine has 3 reels and each reel will have numbers ranging from 1 to 10. The user can choose how many chips they start out with. They are allowed to wager between 1 to the amount of bank they currently have on each spin. If they match 3 numbers, they will win 10 times their wager. If they match 2 numbers they will win 3 times their wager.
Lab05.py You will start out with lab05.py program. Notice that it has been stubbed out with functions and much of the main program has been written. Most of your work will just be in making each function work correctly. This can help you see how you can break a program down into smaller sub-problems which makes design and testing much easier.
All of these functions have been stubbed out to return a literal value. You can actually run the program and see it running.
For testing below, make sure that any functions are before the if name == “main” section and anything in the main portion of the program is indented under this if statement.
Slot_UnitTests will run your functions and check for valid results. They don’t test everything, but if you get all the tests passing then you’ll have pretty good indication that you’ve written most of the functions effectively.
You can edit and run the Slot_UnitTests.py in python just like your program. However, make sure you save your lab05.py program before you run the tests. It can’t tell that you’ve got some unsaved changes in the editor.
For the program first I did some edits on the functions. Then I added text to ask for user input for the functions. Then after I tested to make sure the program ran properly. During the process I had to make sure spacing/indentions were correct or the program would not function correctly. I also changed some of the if_main and added extra code. Then I tested the whole thing to make sure it worked.
The program starts and first asks the user to choose a how many chips they wanted. The value has to be between one and hundred, if the user inputs a value not in that range the program will tell then to enter a value between one and hundred. Then once they enter a value within the range, the program will ask for a wager amount. After you enter the wager amount that is within your bank, the program will spin the slot. The slot will show you what number you got and if you matched any wheels. You can keep wagering as long as you have chips. Then once you lose all your chips it will tell you how much bank you lost in however many spins. Then it'll ask you if you want to play again.