Prototype: chooseSpot(List<Spot>, String vehicleKind) returns a spot ID or null. Kinds are exactly motorcycle/car/van in that size order; identifiers are nonempty and inventory IDs unique. Validate every spot, preserve input, then select smallest compatible kind and ID.

Final: ParkingLot(List<Spot>) owns copied inventory. park(vehicleId,kind) returns Ticket or null for capacity failure; duplicate active vehicles raise. IDs start at 1 and advance only on success. release(ticketId) returns the released Ticket or null once absent. activeTickets() is ticket-ID ordered; availableSpots() is kind-rank/ID ordered. Releasing permits that vehicle to park again.

The complete public API is in Exercise.java. All domain classes are public static nested classes of Exercise; construct them as new Exercise.ClassName(...). Do not implement a solution in the test runner. Each instance owns independent state. Unless explicitly allowed, null inputs are outside the domain. Failed operations leave state unchanged; validation happens before mutation.

Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
No results yet.

Complete the starter code, then run the checks.
Results and errors will appear here.

Java runs on this device with CheerpJ 4.3.