Design an object-oriented parking lot system
Company: Uber
Role: Software Engineer
Category: Software Engineering Fundamentals
Difficulty: medium
Interview Round: Technical Screen
Design an object-oriented model for a parking lot management system.
Requirements:
- The parking lot has multiple levels; each level has multiple parking spots.
- Each spot has a size: small, medium, or large.
- Vehicles can be of different types: motorcycle, car, or bus/truck.
- A vehicle can only be parked in a spot of a compatible size. A bus or truck may require multiple adjacent large spots.
- The system must support:
- Vehicle entry: find and reserve an appropriate spot (or group of spots) for an incoming vehicle.
- Vehicle exit: free the spot(s) and calculate the parking fee based on time parked.
- Query operations: report the number of available spots per size and per level, and whether the lot is full.
Assumptions:
- Ignore distributed systems concerns; you are designing an in-process object-oriented model, not a networked service.
- You may assume time and payment processing are handled by simple helper components.
Describe:
- The main classes, their responsibilities, and key attributes.
- The relationships between classes (inheritance, composition, etc.).
- The main methods needed to support the above operations.
- Any design patterns or principles (for example, SOLID) you apply.
Quick Answer: This question evaluates object-oriented design competency, including class modeling, responsibility assignment, relationships (inheritance and composition), and familiarity with design patterns and SOLID principles for representing constraints like spot sizes and vehicle types.