Medium
Design a Vending Machine Controller Object-Oriented Design Interview
Design a vending machine that manages inventory, accepts money, supports product selection and cancellation, returns change, and enforces a clear transaction state machine.
1. Problem Statement
Design a vending machine that tracks products and stock, accepts supported denominations, lets a user select or cancel, dispenses only after sufficient payment, and returns exact change safely.
2. Live Coding Format
Work in the provided coding workspace while explaining your decisions to the live interviewer. Validation may use inline tests, examples, comments, or a verbal walkthrough.
3. Key Focus Areas
- 1Transaction state machine
- 2Inventory and slot modeling
- 3Payment, refund, and exact-change calculation
- 4Atomic dispense and failure handling
4. What Strong Candidates Should Demonstrate
- ✓Model a transaction lifecycle with explicit legal states and transitions.
- ✓Separate inventory, payment/change, and orchestration responsibilities.
- ✓Preserve money and stock invariants when a purchase cannot complete.
- ✓Design exact-change behavior and understand denomination-algorithm limits.
Want interactive feedback?
Practice this problem in the live coding workspace while the interviewer probes your clarification, implementation, trade-offs, and validation.
Start InterviewCore Concepts
Object-Oriented DesignState PatternInventory
