Design and implement a Parking Lot Management System that supports parking and unparking of vehicles, parkingTicket generation, fee calculation, and management of multiple floors and spot types.
- Multiple Floors: The parking lot can have multiple floors.
- Parking Spots: Each floor has multiple parking spots of different types (e.g., car, bike, truck).
- Vehicle Types: Support for different vehicle types (see
vehicletype/). - Ticketing: Generate a parkingTicket when a vehicle is parked.
- Unparking: Allow vehicles to unpark and calculate the parking fee.
- Fee Calculation: Support for different fee strategies (see
fee/). - Spot Allocation: Allocate the nearest available spot of the correct type.
- Extensibility: Easy to add new vehicle types, spot types, or fee strategies.
- ParkingLot: Main class managing the entire parking lot, floors, and overall operations.
- ParkingFloor: Represents a single floor in the parking lot, manages its spots.
- ParkingSpot: Represents an individual parking spot, knows its type and occupancy.
- Ticket: Represents a parking parkingTicket issued when a vehicle is parked.
- VehicleType (in
vehicletype/): Enum or classes for different vehicle types. - Fee Calculation (in
fee/): Classes for calculating parking fees based on duration and vehicle type.
- Methods:
parkVehicle(Vehicle vehicle)unparkVehicle(String ticketId)addFloor(ParkingFloor floor)getAvailableSpots()
- Fields: List of floors, mapping of tickets, etc.
- Methods:
getAvailableSpot(VehicleType type)parkVehicle(Vehicle vehicle)unparkVehicle(String spotId)
- Fields: List of spots, floor number.
- Methods:
isAvailable()assignVehicle(Vehicle vehicle)removeVehicle()
- Fields: Spot ID, type, current vehicle.
- Fields: Ticket ID, vehicle info, entry time, spot info.
- Enum or classes for vehicle types (Car, Bike, Truck, etc.)
- Methods:
calculateFee(Ticket parkingTicket, Date exitTime) - Extensible: Add new strategies for fee calculation.
- Strategy Pattern: For fee calculation strategies.
- Factory Pattern: (If used) For creating vehicles or spots.
- Singleton Pattern: (If used) For ParkingLot instance.
ParkingLot lot = new ParkingLot();
lot.addFloor(new ParkingFloor(...));
Ticket parkingTicket = lot.parkVehicle(new Car("KA-01-1234"));
lot.unparkVehicle(parkingTicket.getId());See ParkingLotDemo.java for a sample usage of the parking lot system.
- Add a new vehicle type: Update or add to
vehicletype/. - Add a new fee strategy: Implement a new class in
fee/. - Add new spot types or floors: Extend
ParkingSpotorParkingFloor.
