Write a script that creates and uses a ParkingLot class which helps to control automated parking lots. Both the class code and the code in the main body of the script should be in the same script file (as shown in the unit 10 example script).
The ParkingLot class should have the following six methods (all of which require the self parameter as well as any other additional parameters):
Parameters used to initialize data variables are: name, totalSpaces, filledSpaces. There is no return.
No additional parameters. Return a string with the name of the lot, the number of filled parking spaces, and the total number of parking spaces.
No additional parameters. If the lot has available spaces, add one to the filledSpaces data variable and return a string that says "Open Gate". If the lot has no available spaces, return a string that says "Lot full, gate stays closed".
No additional parameters. Subtract one from the filledSpaces data variable and return a string that says "Open gate".
No additional parameters. If the lot has available spaces, return a string that says "Spaces available", otherwise, return a string that says "No spaces available".
No additional parameters. Return the value of the filledSpaces data variable.
lot1 = ParkingLot("Downtown", 80, 79) lot2 = ParkingLot("Northside", 40, 20) print(lot1) print(lot1.lotStatus()) gateAction = lot1.letCarIn() print(gateAction) print(lot1.lotStatus()) gateAction = lot1.letCarIn() print(gateAction) gateAction = lot1.letCarOut() print(gateAction) print(lot1) print(lot2)
Test results should show as follows:
Lot: Downtown Filled spaces: 79 Total spaces: 80 Spaces available Open gate No spaces available Lot full, gate stays closed Open gate Lot: Downtown Filled spaces: 79 Total spaces: 80 Lot: Northside Filled spaces: 20 Total spaces: 40
OPTIONAL CHALLENGES: There are no optional challenges this week. Instead, work on the final project.