Describe the bug
In ParkingLot.ts, the parkCar function successfully parks the vehicle in the Spot object but fails to save the mapping in this.carSpotMap.(Typescript)
To Reproduce
- Create a ParkingLot instance.
- Park a car using
lot.parkCar(vehicle).
- Try to unpark the same car using
lot.unparkCar(vehicle).
Expected behavior
The car should be unparked successfully.
Actual behavior
The system throws an Error: "Car is not Parked" because the map lookup returns undefined.
Suggested Fix
Add this line in ParkingLot.ts inside the parkCar method:
this.carSpotMap[vehicle.getNumber()] = availableSpot;