Requirements

Determine the different ways the system will be used. This includes main functions the system needs to perform and who will use it.

1 users can see the available parking spot, not available parking spot.

2 user can see one parking floors, spot size, checking the parking.

3 user can see the fee calculation based on parking duration.



Define Core Objects

Based on the requirements and use cases, identify the main objects of the system...

ParkingSystem{

List floors;

}


Floors{

long id;

List availableSpotList;

List usedSpotList;

}


ParkingSpot{

long id;

int vehicleSize;

boolean available;

long userId;

int fee;

}


ParkingOrder{

long userId;

long spotId;

long startTime;

long endTime;

int cost;

int status;

}


User{

int id;

String name;

}






Analyze Relationships

Determine how these objects will interact with each other to fulfill the use cases...


user can get available floors parking spot from ParkingSystem

user can occupy the parking spot check in the ParkingSpot, and create a Parking order, after success, the parking spot move from availableSpotList to usedSpotList.

user can get the parking spot fee from ParkingOrder cacluated



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...






Design Patterns

Consider using design patterns (e.g., Factory, Singleton, Observer, Strategy) that fit the problem...






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.


@data public class ParkingSystem{ List<Floors> floors; } public interface IParkingService{ public ParkingSystem getParkingSystem(); public boolean occupyParkingSpot(); public boolean finishParkingOrder(long orderId); public ParkingOrder getParkingOrder(); public pay(); } @data public class Floors{ Long id; List<parkingSpot> availableSpotList; List<parkingSpot> usedSpotList; } @data public class ParkingSpot{ long id; int vehicleSize; boolean available; long userId; int fee; } @data public class ParkingOrder{ long userId; long spotId; long startTime; long endTime; int cost; int status; } @data public class User{ int id; String name; }




Adhere 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.)...






Consider Scalability and Flexibility

Explain how your design can handle changes in scale and whether it would be easily to extend with new functionalities...






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...