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#2: 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 park_vehicle 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 depart_vehicle 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 available_spaces that prints the number of remaining parking spaces in the garage.
List Parked Vehicles: Add a method called list_vehicles that prints a list of all currently parked vehicles' license plates.
-----------------------------------------------------
Example Usage:
#Creating an instance of ParkingGarage with user's input 5 parking spaces
#Parking some vehicles with the following user's inputs for plate numbers:
"XYZ 1234"
"ABC 5678"
#Listing parked vehicles:
Output should list
"XYZ 1234",
"ABC 5678"
#Departing the following user's input for plate number: "XYZ 1234"
#Checking available spaces: Output should be 4
#Attempt to park another vehicle when the garage is full: user's inputs are
"DEF 9101"
"GHI 1112"
"JKL 1314"
"MNO 1516"
"PQR 1718" # Should print "Garage is full"
```
Write the complete implementation of the ParkingGarage class based on these specifications.
1
Q# 2 : Create a Python class named ParkingGarage

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!