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

  • 1
    Transaction state machine
  • 2
    Inventory and slot modeling
  • 3
    Payment, refund, and exact-change calculation
  • 4
    Atomic 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.

Continue to Dashboard

Core Concepts

Object-Oriented DesignState PatternInventory

Continue preparing

Build a complete software engineer mock interview plan

Related Object-Oriented Design

Design an ATM Transaction Engine

Design an ATM that authenticates a card and PIN, and supports balance inquiry, cash withdrawal with denomination dispensing, and deposits, including session/state handling and hardware abstractions.

Related Object-Oriented Design

Design a Car Rental System

Design a car rental domain model covering vehicle categories and vehicles, branches, customers and drivers, a rental date range, rate-based quotes, reservations, pickup rental agreements, and return inspection with extra charges — preventing overlapping rentals of the same vehicle.

Related Object-Oriented Design

Design a Cricket Information Platform

Design a cricket scoring domain model covering teams and players, a match, innings, overs and deliveries, batting and bowling scorecards, extras and wickets, striker rotation, over completion, and match results for a configurable limited-overs format.

Related Object-Oriented Design

Design a Group Expense-Splitting Ledger

Design a system where users form groups, log shared expenses using pluggable splitting strategies (equal/exact/percentage), maintain pairwise balances, and settle debts.