# lld-parking-lot A thread-safe parking lot in plain Java, built the way a low-level-design interview expects: requirements, entities, patterns, concurrency, extensions. Companion to [Low-Level Design Interview in Java: Parking Lot System, Step by Step](https://ankurm.com/low-level-design-interview-parking-lot-system-java/). No framework, no runtime dependencies. JUnit 6 is used for tests only. ## Versions | Component | Version | Verified against | |---|---|---| | JDK | 25.0.4.1+1 (Temurin LTS); also compiled and run with `--release 21` on OpenJDK 21 | `java -version`; the walkthrough output is byte-identical on both | | JUnit Jupiter | 6.1.3 | `org.junit.jupiter:junit-jupiter` metadata on Maven Central | | Maven | 3.9.11 | `mvn -version` | ## Run it ```bash cd lld-parking-lot ./scripts/run.sh # compiles with javac, prints the walkthrough (no Maven needed) mvn test # 10 tests, including two concurrency tests ./scripts/run-all.sh # regenerates everything in output/ ``` ## Layout ``` src/main/java/com/ankurm/interviewlab/parking/ VehicleType, SpotSize enums; SpotSize.canHold(VehicleType) is the only "does it fit" rule Vehicle, Ticket, Receipt immutable records ParkingSpot occupancy is one AtomicReference compare-and-set ParkingFloor ordered spots AllocationStrategy Strategy: NearestFirstStrategy, BestFitStrategy PricingStrategy Strategy: HourlyPricing (grace period, partial hours round up) AvailabilityListener Observer: the entrance display board ParkingException LotFull, AlreadyParked, UnknownTicket ParkingLot the aggregate: park(), exit(), freeSpots() Demo prints output/01-walkthrough.txt src/test/java/.../ParkingLotTest 10 tests; Clock is injected so nothing sleeps output/ captured real output ``` ## Captured output | File | What it shows | |---|---| | `output/01-walkthrough.txt` | Enter, leave, fail three ways, and the two allocation strategies placing the same motorcycle differently | | `output/02-test-results.txt` | One line per test, generated from the Surefire XML report | ## License MIT, see the repository root.