Files | |
| file | Vendotron.py |
| Runs a vending machine emulator in the terminal. | |
Classes | |
| class | Vendotron.Drink |
| A small struct representing a drink. More... | |
| class | Vendotron.Currency |
| A small struct representing a denomination of US currency. More... | |
| class | Vendotron.State |
| The current state of the Vendotron. More... | |
Functions | |
| def | Vendotron.display (message) |
| Display a Vendotron message in a pretty format. More... | |
| def | Vendotron.get_change (price, payment) |
| Calculate the change required based on a given payment. More... | |
| def | Vendotron.handle_key (key) |
| Catch a key press and do the appropriate action. More... | |
| def | Vendotron.main () |
| Entry point for the Vendotron program. More... | |
Variables | |
| dictionary | Vendotron.drinks |
| A dictionary of all drinks in the machine. More... | |
| def Vendotron.display | ( | message | ) |
Display a Vendotron message in a pretty format.
| message | The message to be displayed |
| def Vendotron.get_change | ( | price, | |
| payment | |||
| ) |
Calculate the change required based on a given payment.
| price | A price in USD, expressed as a real number divisible by 0.01 |
| payment | A dictionary containing the amount of each denomination that was paid. Keys are the denomination value and Values are the frequency of said denomination. |
| def Vendotron.handle_key | ( | key | ) |
Catch a key press and do the appropriate action.
0-7: insert a currency of one of these denominations:
| def Vendotron.main | ( | ) |
Entry point for the Vendotron program.
Run the Vendotron program, first displaying a welcome message and then responding to user actions. If the user hasn't pressed any buttons in a while (30s), display a random slogan. For user actions see handle_key . Also accepts CTRL+c to terminate the program swiftly.