Based on the requirements and use cases, identify the main objects of the system and analyze how they interact and relate to each other...
Here's a Class Diagram illustrating the relationships of the core objects and too each other:
classDiagram
class VehicleType{
<<enumeration>>
MOTORCYCLE
COMPACT
REGULAR
LARGE
EV
}
class ParkingSpotType{
<<enumeration>>
MOTORCYCLE
COMPACT
REGULAR
LARGE
EV
}
class TicketStatus{
<<enumeration>>
OPEN
CLOSED
LOST
}
class ParkingGarage {
+ConcurrentHashMap<int, ParkingFloor> floors
+TicketService ticketService
+CreateTicket() Ticket
+CloseTicket() Ticket
}
class TicketService {
-List<Tickets> tickets
-Queue<Vehicle> waitList
+CreateTicket(floors) int
+CloseTicket(ticketId) int
+alertSpotOpen() void
}
class Vehicle {
+getMake/Model/Year/VehicleType() String/Int
+setMake/Model/year/VehicleType() void
+String make
+String model
+int year
+VehicleType vehicleType
+Driver user
+String liscensePlateNum
}
class ParkingFloor {
+getAvailableSpots() availableSpots
+updateParkingSpot(parkingSpot) bool
+int floorNum
+ParkingSpots[] spots
+Queue<ParkingSpots> availableSpots
}
class ParkingSpot {
+canFitVehicle(Vehicle v) bool
-ParkingSpotType parkingType
-int spotNum
-Vehicle Vehicle
-Boolean isAssigned
}
class Driver {
+method() void
+String fn
+String ln
+int age
+String email
}
class Ticket {
+Date check_in
+Date check_out
+TicketStatus status
+Int fee
+ParkingSpot spot
+feeCalculation() Float
}
class PricingStrategy{
<<interface>>
+calculate(Ticket ticket) BigDecimal
}
class DurationBasedPricingStrategy{
+calculate(Ticket ticket) BigDecimal
}
class VehicleTypePricingStrategy{
+calculate(Ticket ticket) BigDecimal
}
class EventPricingStrategy{
+calculate(Ticket ticket) BigDecimal
}
ParkingGarage *-- TicketService
TicketService "1" --> "*" Ticket
TicketService "1" --> "0..*" Vehicle
Vehicle "1" --> "1" Driver
ParkingGarage "1" --> "0..*" ParkingFloor
ParkingFloor "1" --> "0..*" ParkingSpot
ParkingSpot "1" --> "0..1" Vehicle
PricingStrategy <|-- DurationBasedPricingStrategy : implements
PricingStrategy <|-- VehicleTypePricingStrategy : implements
PricingStrategy <|-- EventPricingStrategy : implements
For each class, define the attributes (data) it will hold and the methods (functions) that operate on the attributes. Ensure they align with the object's responsibilities and adhere to the principle of encapsulation. Write your code in the code editor below.
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...
Design Tradeoffs:
Solid Principles:
Yes. PricingStrategy is small and focused: BigDecimal calculate(Ticket ticket);
Future improvement: