OOP Design
16 classic interview prompts, each with the canonical class breakdown.
Design an object-oriented parking lot with multiple levels, multiple spot sizes (motorcycle, compact, large), and dynamic pricing. A ticket is issued on entry and used to compute the bill on exit.
Design a library system that tracks books, members, check-outs, holds, and fines. A single title may have many physical copies; members can place holds when all copies are checked out.
Design an elevator control system for a building with N elevators and F floors. Riders press hall buttons on each floor (up/down) and car buttons inside each elevator. The system must dispatch efficiently and serve every request.
Design a vending machine that holds inventory across slots, accepts coins and bills, dispenses a product, and returns correct change. Model the full transaction lifecycle including cancellation.
Design an ATM that authenticates a cardholder, then supports balance inquiry, withdrawal, deposit, and transfer. Enforce per-account daily withdrawal limits and machine cash limits.
Design a chess game: model the board, pieces, legal-move generation, turn order, and game-end detection (checkmate, stalemate, draws). Focus on a piece hierarchy that's easy to extend.
Design an Amazon-style online bookstore: catalog, search, cart, checkout, orders, and payment. Focus on the domain model and how state moves through the order lifecycle.
Design a hotel reservation system that supports searching available rooms by date range and room type, booking with pricing, modifying or cancelling reservations, and check-in/check-out at the property.
Design an in-process pub/sub system: publishers post messages to topics, and subscribers receive messages from topics they subscribe to. Support multiple subscribers per topic, retention, and delivery guarantees.
Design a movie ticket booking system: theaters with multiple screens, movies showing at scheduled times, seat selection with temporary holds during checkout, and payment that confirms the booking.
Design the core of a Splitwise-style app: users form groups, add expenses paid by one person and split equally, by exact amounts, or by percentage, and see who owes whom. Support settling up and simplifying debts within a group.
Design an in-process rate limiter library that services call before handling a request. It must limit per key (user, API key, or IP), support several algorithms, and stay correct under concurrent access.
Design an in-memory file system that supports directories and files, path-based operations (mkdir, ls, create, read, write, move, and delete), and metadata such as size and timestamps.
Design a multiplayer Snake and Ladder game: a board of 100 cells with snakes and ladders, two or more players taking turns rolling a die, and a winner who lands exactly on the last cell.
Design a logging library in the style of Log4j or Logback: named loggers, log levels, multiple destinations (console, file, and remote), configurable formats, and minimal overhead on the calling thread.
Design the object model for a notification service that sends email, SMS, and push messages. Callers send an event like 'order shipped'; the service renders a template, respects user preferences and quiet hours, retries failures, and avoids duplicate sends.