Assumptions:
Lot - object to represent a particular lot in the parking lot. Has an id, a rate, a size, whether the lot if available to lease, when the lot is leased, and who leased it.
ParkingLot - responsible for managing the lots. It knows how many lots exist on each level. It can answer whether a lot is available for a size and duration. It can mark a lot as leased for a size and driver. It can mark a lot as returned.
ParkingLotFactory - responsible for creating lots and the parking lot.
A ParkingLot has many Lots.
Design inheritance trees where applicable to promote code reuse and polymorphism. This step involves identifying common attributes and behaviors that can be abstracted into parent classes...
Factory pattern to create the Lots and ParkingLot instances.
Attributes: For each class, define the attributes (data) it will hold...
Methods: Define the methods (functions) that operate on the attributes. Ensure they align with the object's responsibilities and adhere to the principle of encapsulation.
public class Car { ... } // Example
Single Responsibility Principle:
Open closed principle:
The design could extend to include a LotFactory if lot rates or lot sizes were to change in the future. A ParkingLot could hold a LotFactory to create lots instead of the ParkingLotFactory. If more than one lot may be rented at the same time, concurrency would need to be implemented. Instead of an array of Lots, suggest to use a synchronised list instead.
Try creating a class, flow, state and/or sequence diagram using the diagramming tool. Mermaid flow diagrams can be used to represent system use cases. You can ask the interviewer bot to create a starter diagram if unfamiliar with the tool. Briefly explain your diagrams if necessary...