1. Problem Statment
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.
This solution is for reference purpose. Please, do not copy-paste it. Companies are smart enough to catch if you are cheating. If your solution got rejected due to this we're not responsible for it.
2. Solution Approach
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.
The solution of above problem statement is available here. You can directly download this solution from here.
3. Supported Commands
To create a Parking lot. Where
nis the size of the parking lot
To park the car in the parking lot and prints the allocated slot in the parking lot. Where
registration_numberis given registration number for the car and
colouris given colour for the car
To leave the parking lot from desired slot and prints the leaving slot. given slot number. Where
slotis given sloat number
To check the status of Parking Lot
To prints the registration number of the cars for the given colour. Where
coloris given colour
prints the slot number of the cars for the given number. Where
registration_numberis given registration number.
To prints the slot number of the cars for the given colour. Where
colouris given colour.
4. Running Application
4.1 Running the application in File mode:
4.2 Running the application in Interactive mode:
5. Test Cases
- Total number of test cases - 14
- Code coverage - 86%
5.1 For running the tests
5.2 For calculating code coverage
coverage run Tests.py coverage report
6. Running the application in a Docker Container
Build the image:
docker build -t parkinglot:1.0 .
6.1 Running the application in Interactive mode:
docker run -it parkinglot:1.0 ./ParkingLot.py
6.2 Running the application in File mode:
docker run -it parkinglot:1.0 ./ParkingLot.py input.txt