Design a Parking Lot System
Medium
|
Design
OOP
System Design
|
Solved: Feb 24, 2026
Complexity Analysis
Time Complexity:
Space Complexity:
Problem Description
Design an Object-Oriented system for a Parking Lot.
Requirements:
- The parking lot should have multiple levels.
- Each level has a certain number of spots.
- The parking lot can park different types of vehicles (Motorcycles, Cars, and Buses).
- The parking lot has motorcycle spots, compact spots, and large spots.
- A motorcycle can park in any spot.
- A car can park in either a single compact spot or a single large spot.
- A bus can park in five large spots that are consecutive and within the same row.
Approach
This is a pure Object-Oriented Design problem. Core classes will include Vehicle (abstract), Motorcycle, Car, Bus, ParkingSpot, Level, and ParkingLot. Use Enums for VehicleSize.
Solution
// Add your implementation here...
public enum VehicleSize {
Motorcycle,
Compact,
Large
}
public abstract class Vehicle {
protected int spotsNeeded;
protected VehicleSize size;
protected String licensePlate;
public int getSpotsNeeded() { return spotsNeeded; }
public VehicleSize getSize() { return size; }
}
public class ParkingLot {
// Implement levels and parking logic
}