This lab simulates the Vendotron machine. More...
Functions | |
| def | Lab_01.on_keypress (key) |
| Callback function which is called when a key has been pressed. | |
Variables | |
| int | Lab_01.change = 0 |
| int | Lab_01.order = 0 |
| int | Lab_01.state = 0 |
| Lab_01.last_key = None | |
| Lab_01.twenty = math.floor(change/(20*100)) | |
| Variable defining number of twenties to return. | |
| Lab_01.ten = math.floor(change/(10*100)) | |
| Variable defining number of tens to return. | |
| Lab_01.five = math.floor(change/(5*100)) | |
| Variable defining number of fives to return. | |
| Lab_01.one = math.floor(change/(100)) | |
| Variable defining number of ones to return. | |
| Lab_01.quarter = math.floor(change/(25)) | |
| Variable defining number of quarters to return. | |
| Lab_01.dime = math.floor(change/(10)) | |
| Variable defining number of dimes to return. | |
| Lab_01.nickel = math.floor(change/(5)) | |
| Variable defining number of nickels to return. | |
| Lab_01.penny = math.floor(change) | |
| Variable defining number of pennies to return. | |
| tuple | Lab_01.change_tuple = (penny , nickel , dime , quarter , one , five , ten , twenty) |
This lab simulates the Vendotron machine.
A finite state machine first requests that the user input change using number keys 0 - 7, and at any point the user can request one of the four drinks by inputting the appropriate letter. The FSM then checks that the inputted funds are sufficient and either asks for more money or dispenses the requested drink. The machine then initializes again and prints the welcome message.