Design
Vending Machine
Design a vending machine that dispenses products, handles payment, and manages inventory.
01 - Why interviewers ask this
It's the textbook example for the State pattern — interviewers use it to check that you model states as objects instead of littering the code with if/else flags.
02 - Where this system exists in the real world
You interact with this design every day.
Snack, drink, and ticket vending machines
Self-checkout kiosks with cash/card acceptance
Automated parcel lockers with item dispensing
03 - What you'll master
Solve this once. Know it forever.
Apply the State pattern to a physical workflow
Model coin/note insertion, change, and refunds
Handle out-of-stock and insufficient-payment edge cases
04 - What you'll design
7 functional · 4 non-functional requirements.
Display available products with prices
6 more requirements inside
Sign in to unlock the full brief and start designing
05 - Companies that ask this
You may face this exact question in your next interview.
Ready?
Open the canvas.
Design it yourself.
See all requirements, use staged hints, run your code, and compare with community discussions - all on the same canvas.
Start Solving