Design Projects: Classic Systems · Code review
Review: Parking Lot - The Exit Display PR
A free code review from the Design a Parking Lot skill. Read it here, then solve it in the app in Java or Python.
- Easy
- Code review
- Free
- Java and Python
The problem
Your task
Review this pull request before it's merged. Read parkinglot/ParkingLot.java (in Python, parkinglot/parking_lot.py), click the margin next
to each line with a problem, and say what kind of problem it is, how bad it is, and why. There are
problems planted in this code - the count is shown above the code - and the review is graded on
whether you find them without crying wolf.
The pull request
PR #214 - Show the plate at the exit gate
The exit gate's display now shows the plate a ticket was issued for (
plateFor), and the new operations dashboard lists every spot on the level (getSpots). (Python:plate_forand thespotsproperty.) Parking and unparking are unchanged.
What the lot must do
parkVehicle(vehicle)puts the vehicle in a free spot of its size - MOTORCYCLE in SMALL, CAR in MEDIUM, BUS in LARGE - and returns a new ticket, ornull(None) if none is free. In Python the methods arepark_vehicle,unpark_vehicleandavailable_spots.unparkVehicle(ticket)frees that ticket's spot and returnstrue; an unknown ticket returnsfalseand changes nothing. A ticket is good for one exit - the exit gate retries requests when the barrier is slow to answer.availableSpots(size)counts the free spots of that size.ParkingSpot(not in this PR) is a plain mutable class:getSize(),isOccupied(),setOccupied(boolean)- in Python the attributessizeandoccupied.
How it's graded
- Flag the lines you would comment on and say what kind of problem each is. Submit shows every planted defect, with what goes wrong and the fix.
- Stuck? Hints come in four steps, from a nudge to a code skeleton, each costing part of the points.
More problems in Design a Parking Lot
Review the code Review: Parking Lot - The Exit Display PR free
No card needed. Lessons, practice questions and easy problems are free forever.
Free plan, no card · 7-day Pro trial · Cancel anytime