Inkline
Menu

Parking lot

Templates
Parking lot 10 items and 10 connections. Parking has11..* 11..* holds0..10..1 issues 10..1 ParkingLot−id: UUID−name: String+getInstance(): ParkingLot+park(vehicle: Vehicle): Ticket+leave(ticket: Ticket): Payment Level−floor: int+findSpot(type: SpotType): ParkingSpot ParkingSpot−number: int−type: SpotType+isFree(): boolean «enumeration»SpotTypeCOMPACTLARGEMOTORBIKEELECTRIC «abstract»Vehicle#plate: String+size(): SpotType Car Truck Ticket−issuedAt: Instant+close(): Duration «interface»Payable+pay(amount: Money): Receipt Payment−amount: Money−status: PaymentStatus
Parking lot — preview
Class

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"