Requirements
- 10K to 30K parking slots.
- Assume there are 4 entrances and 4 exits.
- Ticket and spot allocated at the entrance.
- The spot should be near the entrance the user entered.
- Different types of spots for bike, handicap, cars, truck.
- Hourly parking rate.
- Pay parking fee using cash and cards.
- Monitoring system for total cars entered etc.
Different actors
- Parking lot system
- Entry/exit terminal
- Printer
- Payment processor
- Parking spot
- Ticket
- Database
- Monitoring system
Parking spot
- Parent class parking spot
- Child class handicapped parking spot
- Child class car parking spot
- Child class truck parking spot
Ticket
- Ticket class
- Ticket id
- Parking spot id
- Parking spot type
- Issue time
Terminal
- Parent class terminal
- Child class entry terminal: getTicket(parkingSpotType)
- Child class exit terminal: acceptTicket(ticket)
Parking assignment strategy
- Class Parking assignment strategy
- Get parking spot method
- Release parking spot method
- Since we have 4 entrances we will have 4 heaps.
- Once a parking spot is reserved make sure you to remove it from all the 4 heaps.
Payment
- Parent class Payment processor
- Child class credit card payment processor
- Child class cash payment processor
Tariff calculator
- Calculate tariff method(start time, parking spot type)
Monitoring system
- Use logger
Parking lot application
- This application uses a singleton design system.
- Will be composed of above smaller objects.
- Use a factory design pattern to instantiate above smaller objects.
- Application accept XML configuration as input. Input like parking spot type, payment type.
Remember the pattern – stampped
1 strategy
2 ticket
3 application
4 monitoring
5 processor
6 printer
7 entry/exit terminal
8 database
LikeLike
Try using the following pattern
1 input classes
2 output classes
3 service classes
4 database classes
5 application & configuration
6 monitoring&logging
For ATM
1. input – admin
AdminInput – adminUserId, adminOTP, totalInputCash, dbUpdate()
2. input – customer
CustomerInput – userCard, userId, userPin, userOtp, cashNeeded
userCardBase – visaChild, masterCardChild
3 Output
Printer bool Print()
Receipt – accountNumber, balance, amountTaken, dateTime
cardEjector
cashEjector
4 Service
UserValidation – chain pattern (verify card, verify pin, verify otp, verify balance)
AmountValidation – chain pattern (bank balance validation, available denomination validation)
AdminValidation – chain pattern
CashTrayCalculator
5 Database
CashTray[] (100, 200, 500)
CRUD
6 Application – singleton, factory pattern
7 Monitoring
LikeLike