Requirements
- Multi-Floor Structure: The parking lot should be able to handle multiple floors, each of which can contain different types of parking spots.
- Spot Assignment Based on Vehicle Size: The system must assign parking spots based on the size of the vehicle. For example, small vehicles (like motorcycles) should be able to park in small, medium, and large spots, while large vehicles (like trucks) should only be able to park in large spots.
- Availability Checking: The system should be able to check the availability of parking spots in real-time and return the first free spot that allows for the vehicle being parked.
- Parking Ticket Generation: Upon entry, the system must create a parking ticket that records details such as the vehicle’s information, the assigned spot, the time of entry, and a unique ticket ID.
- Fee Calculation: The system should calculate the parking fee based on the duration the vehicle is parked, using pricing strategies such as hourly, daily, or event-based pricing.
- Ticket Processing on Exit: When a vehicle exits, the system must validate the parking ticket, calculate the total fee based on the duration, and update the availability of the parking spot.
Core Objects & Relationships
- ParkingLot overall class
- ParkingSpot and abstract class to general parking spot
- SmallParkingSpot, MediumParkingSpot, LargeParkingSpot extends ParkingSpot
APIs & Class Members (write code)
public class ParkingLot{
List<ParkingSpot> spots
public ParkingSpot findFirstAvaliableSpott(Vehicle vehicle) {
for (ParkingSpot spot: spots){
if (spot.park(vehicle)){
return spot;
}
}
return null;
}
}
// if return null means no avaliable spot for this type of vehicle
Tradeoffs, SOLID & Scalability
Explain design tradeoffs you considered. Check and explain whether your design adheres to SOLID principles. Explain how your design can handle changes in scale and whether it would be easy to extend with new functionalities. Identify areas for future improvement...