7
Back to Problem Dungeon

Vending Machine

medium

Step 1: Requirements

Requirements

Questions to ask the interviewer

  1. What payment methods — coins, notes, card?
  2. Multiple products or just one?
  3. Does it give change?
  4. Do we need inventory tracking?
  5. Admin refill and cash collection?

Functional requirements

  • Machine holds multiple products in slots, each with a price and quantity.
  • User inserts money, selects a product, and receives it.
  • Machine returns change if overpaid.
  • States: Idle → HasMoney → Dispensing → ReturningChange.
  • Admin can refill products and collect cash.
  • Reject if insufficient funds or out of stock.

Non-functional requirements

  • State transitions must be safe (no dispensing without payment).
  • Extensible to new payment methods.

Assumptions

  • Cash-only for simplicity (card adds a payment gateway).
  • Exact denomination tracking not needed — just total amount.

1 / 7 — Requirements