Design a vending machine. A person inserts money, picks a product, and the machine dispenses it and returns change. It must handle sold-out items, too little money and cancellations.
It must
- The machine holds products in slots with a price and a quantity.
- A person can insert money and sees the balance grow.
- Choosing a product with enough money dispenses it and returns the change.
- Choosing a sold-out product, or with too little money, shows a clear message and keeps the money.
- The person can cancel and get all inserted money back.
Keep in mind
- The machine can only be in one situation at a time: idle, has money, or dispensing.
- Actions that make no sense in a situation must be refused politely (no product with no money).
- Hardware (coin sensors, motors) is out of scope.