Question: Q# 2 : Create a Python class named ParkingGarage that manages parking spaces and tracks vehicles. Specifications: Initialization: When a new ParkingGarage object is instantiated,
Q#: Create a Python class named ParkingGarage that manages parking spaces and tracks vehicles.
Specifications:
Initialization: When a new ParkingGarage object is instantiated, it should initialize with a specific number of parking spaces.
Park Vehicle: Add a method called parkvehicle that allows a vehicle to be added to the garage. This method should accept a vehicle's license
plate number as a parameter. If the garage is full, it should print "Garage is full" and not add the vehicle.
Depart Vehicle: Add a method called departvehicle that removes a vehicle from the garage using the vehicle's license plate number. If the
vehicle is not found, print "Vehicle not found".
Count Available Spaces: Add a method called availablespaces that prints the number of remaining parking spaces in the garage.
List Parked Vehicles: Add a method called listvehicles that prints a list of all currently parked vehicles' license plates.
Example Usage:
#Creating an instance of ParkingGarage with user's input parking spaces
#Parking some vehicles with the following user's inputs for plate numbers:
XYZ
"ABC
#Listing parked vehicles:
Output should list
XYZ
"ABC
#Departing the following user's input for plate number: XYZ
#Checking available spaces: Output should be
#Attempt to park another vehicle when the garage is full: user's inputs are
"DEF
"GHI
JKL
"MNO
PQR # Should print "Garage is full"
Write the complete implementation of the ParkingGarage class based on these specifications.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
