#K90917. Parking Lot Manager
Parking Lot Manager
Parking Lot Manager
You are given a parking lot system that simulates vehicle entries and exits. The parking lot has a fixed capacity, and vehicles can enter if there is available space and exit at any time. Additionally, you need to support a command that reports the number of available parking spaces.
Implement a class ParkingLot
with the following methods:
enter(license_plate)
: Inserts the vehicle into the parking lot if a vehicle with the same license plate is not already present and if there is space available.exit(license_plate)
: Removes the vehicle with the given license plate from the parking lot.available()
: Returns the number of spaces left, which is given by $$\text{available spaces} = \text{capacity} - \text{number of vehicles}.$$
You are also required to implement a function manage_parking_lot
that processes a series of commands from the standard input and outputs the result of each "available" command.
inputFormat
The input begins with an integer N representing the capacity of the parking lot. Each subsequent line contains a command, one per line. The available commands are:
- enter <license_plate> : Attempt to park a vehicle with the given license plate.
- exit <license_plate> : Remove the vehicle with the given license plate from the parking lot.
- available : Print the number of available parking spaces.
The command input terminates when a line containing only '#' is encountered.
outputFormat
For each 'available' command in the input, output the number of available parking spaces. Each result should be printed on a new line.## sample
5
enter ABC123
enter XYZ999
enter LMN456
available
exit ABC123
available
#
2
3
</p>