Design a Parking lot which can hold n
Cars. Every car been issued a ticket for a slot and the slot been assigned based on the nearest to the entry. The system should also return some queries such as:
- Registration numbers of all cars of a particular colour.
- Slot number in which a car with a given registration number is parked.
- Slot numbers of all slots where a car of a particular colour is parked.
A car consist of Registration number, slot number and it's colour. Likewise our Parking Lot consist slots. For not making it too complicated, I choose a python dictionary for storing cars on slots and implemented the functionalities as accordingly.
-
create_parking_lot
<n
>
To create a Parking lot. Wheren
is the size of the parking lot -
park
<registration_number
> <colour
>
To park the car in the parking lot and prints the allocated slot in the parking lot. Whereregistration_number
is given registration number for the car andcolour
is given colour for the car -
leave
<slot
>
To leave the parking lot from desired slot and prints the leaving slot. given slot number. Whereslot
is given sloat number -
status
To check the status of Parking Lot -
slot_numbers_for_cars_with_colour
<colour
>
To prints the registration number of the cars for the given colour. Wherecolor
is given colour -
slot_number_for_registration_number
<registration_number
>
prints the slot number of the cars for the given number. Whereregistration_number
is given registration number. -
registration_numbers_for_cars_with_colour
<colour
>
To prints the slot number of the cars for the given colour. Wherecolour
is given colour.
./ParkingLot.py input.txt
./ParkingLot.py
- Total number of test cases - 14
- Code coverage - 86%
python Tests.py
coverage run Tests.py
coverage report
docker build -t parkinglot:1.0 .
docker run -it parkinglot:1.0 ./ParkingLot.py
docker run -it parkinglot:1.0 ./ParkingLot.py input.txt
When using running application in Docker, if it gives this error:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"./ParkingLot.py\": permission denied": unknown.
just change the permissions by running
sudo chmod +x ./ParkingLot.py