if not available it rejects request
if available, it assigns parking spot , requests parking spot manager to update the status of parking spot occupancy and creates the ticket
SOLID Priniciples: Single responsibility: entry gate only checks for availability through parking spot manager and issuing ticket, parking spot manager checking parking lot class to check and update availability
use of interfaces and derived classes for open close principle in case of parking spot finder and price calculator, for eg, if in future we want to introduce new price calculation strategy for peak times
Liskov substitution: inherited classes contain all the properties from parent class.
Dependency Inversion: using interface class to create instance instead of concrete derived classes
throwing exceptions if floor or spot being updated is invalid and locks for thread safety, so that when multiple vehicles entry at same time through different entry gates, then concurrency situation can be handled to check spot availability
in future more features can be extended like reservation of slots by creating a separate class, that would reserve spots and issue tickets based on availability.
right now for simplicity I have used int floor and int spot for parking spots but for better readability enums can be used instead
I have used vector
also in future if parking lot is extended to more number of spots or more floors for that maybe parkingLot can have spot and floor , to make that convenient hash maps can be used in place of vector