Parking lot
TemplatesClass
The classic low-level design exercise as a UML class diagram: lot, levels and spots, vehicles, tickets and payments.
What is inside
- Composition and aggregation
- Inheritance and interfaces
- Multiplicities
Use this template
Opens in the playground, no account needed. Sign up to save it.
Show the Inkline text
diagram class "Parking lot"
package parking "Parking" {
class ParkingLot {
- id: UUID
- name: String
+ {static} getInstance(): ParkingLot
+ park(vehicle: Vehicle): Ticket
+ leave(ticket: Ticket): Payment
}
class Level {
- floor: int
+ findSpot(type: SpotType): ParkingSpot
}
class ParkingSpot {
- number: int
- type: SpotType
+ isFree(): boolean
}
enum SpotType { COMPACT; LARGE; MOTORBIKE; ELECTRIC }
}
abstract class Vehicle {
# plate: String
+ {abstract} size(): SpotType
}
class Car
class Truck
class Ticket {
- issuedAt: Instant
+ close(): Duration
}
interface Payable {
+ pay(amount: Money): Receipt
}
class Payment {
- amount: Money
- status: PaymentStatus
}
ParkingLot *-- Level from="1" to="1..*" : has
Level *-- ParkingSpot from="1" to="1..*"
ParkingSpot --> SpotType
ParkingSpot o-- Vehicle from="0..1" to="0..1" : holds
Car --|> Vehicle
Truck --|> Vehicle
ParkingLot ..> Ticket : issues
Ticket --> Vehicle
Payment ..|> Payable
Ticket -- Payment from="1" to="0..1"