Requirements
Determine the different ways the system will be used. This includes main functions the system needs to perform and who will use it.
Main Functions ->
User can book a spot in the parking lot.
Two types of vehicle are allowed Car and bike only.
Fees calculation while exiting the paking lot.
Spot Booking .
There is level in the parking lot.
Define Core Objects
Based on the requirements and use cases, identify the main objects of the system...
Core Objects are
Vehicle -> car and Bike .
Spot -> Attributes isavailable , vechile type , feesperhour,
Paking level -> List of spots, levelNumber
ParkingLotSystem -> main function
Analyze Relationships
Determine how these objects will interact with each other to fulfill the use cases...
PakingLevel has a relation ship with spots .
car and bike is a relationsip with vehicle .
Establish Hierarchy
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...
Car and bike are implmenting the interface which is a parent like interface.
Design Patterns
Consider using design patterns (e.g., Factory, Singleton, Observer, Strategy) that fit the problem...
I will be using Stratgey design pattern for spot assignment and pricing strategy
Define Class Members (write code)
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 { ... } // ExampleAdhere to SOLID Guidelines
Check and explain whether your design adheres to solid principles (Ask interviewer what SOLID principle is if you can not recall it.)...
I am follwing Solid principle
Consider Scalability and Flexibility
Explain how your design can handle changes in scale and whether it would be easily to extend with new functionalities...
Yes its scalable we can add moer vehihcle types .
We can have diff stratgey for pricing and spot assignment .
Create/Explain your diagram(s)
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...
Future improvements
Critically examine your design for any flaws or areas for future improvement...
We can implement observer design pattern as well to notify the user when the time of the user for parking is going to get pver .
We can also implemnent multiThreading to handle multiple car requesting for spot at the same time