There are two classes defined:
ParkingLot()
: It is the main class which is used to initialize a parking lot.
-
createParkingLot(input)
: Creates a parking lot with given input. -
parkCar(input)
: Allocates nearest slot from entry gate to the car. -
leaveCar(input)
: Removes car in given slot in parking lot. -
getParkingStatus()
: Returns an array containing slot number, registration number and color. -
getCarsWithSameColor(input)
: Returns a comma separated string containing registration numbers of cars with same color e.g.KA-01-HH-1234, KA-01-HH-9999, KA-01-P-333
. -
getSlotsWithSameColorCar(input)
: Returns a comma separated string containing slot numbers of car with same color e.g.3, 5, 6
. -
getSlotByCarNumber(input)
: Finds slot number of car for given registration number. It returnsNot found
when car is not present. -
findNearestAvailableSlot()
: Finds nearest free slot.
Car()
new Car(NUMBER, COLOR)
: Constructor used to initialize a car object containing two fields, registration number and color.
Note - Error cases are handled in all functions
-
cd parking_lot
: Navigates to theparking_lot
root folder. -
npm install
: Installs all the dependencies. -
npm run start
: Starts the console application in cli -
npm run test
: Runs all the tests and generate the coverage report.