Documentation for vendotron.py. More...
Functions | |
| def | vendotron.getChange (self, price, payment) |
| A function to calculate the change from a transaction. More... | |
| def | vendotron.VendotronTask () |
| A generator function that implements a finite state machine of the Vendotron vending machine. More... | |
| def | vendotron.kb_cb (key) |
| Callback function which is called when a key has been pressed. | |
Variables | |
| dictionary | vendotron.stateMsgs |
| A dictionary of descriptive messages for each state, used for debugging.1. More... | |
| list | vendotron.moneyKeys = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] |
| string | vendotron.last_key = '' |
| The last key pressed on the keyboard. | |
| dictionary | vendotron.denomValues |
| A dictionary of the cent values of each currency denomination. More... | |
| int | vendotron.paymentCents = 0 |
| the payment value in cents | |
| dictionary | vendotron.chng = {} |
| A dictionary of change from the transaction. | |
| int | vendotron.centsLeft = paymentCents - price |
| The cents remaining to be turned into change. | |
| dictionary | vendotron.v = denomValues[d] |
| The cents value of the current denomination. | |
| vendotron.n = floor(centsLeft/v) | |
| The number of the current denomination needed for change. | |
| def | vendotron.vendo = VendotronTask() |
Documentation for vendotron.py.
This Python program simulates the opperation of a vending machine called the Vendotron.
The Vendotron sells four different types of drinks:
To enter money into the machine the user can press numbers 0-9 on their keyboard, which correspond to increasing monetary denominations (1 = pennies, 2 = nickles, etc.). To select the drink they want the user can press 'c' for Cuke, 'p' for Popsi, 's' for Spryte, and 'd' for Dr. Pupper. To eject any remaining change the user can press 'e'.
| def vendotron.getChange | ( | self, | |
| price, | |||
| payment | |||
| ) |
A function to calculate the change from a transaction.
| price | An integer representing the price in cents |
| payment | A dictionary of the payment bills {'pennies': 0, 'ones' : 0, ...} |
| def vendotron.VendotronTask | ( | ) |
A generator function that implements a finite state machine of the Vendotron vending machine.
The state machine for the Vendotron is shown below:
| dictionary vendotron.denomValues |
| dictionary vendotron.stateMsgs |
A dictionary of descriptive messages for each state, used for debugging.1.