Parcheggio
Crea una classe ParkingLot che gestisca il parcheggio delle auto. Questa classe deve avere diverse funzionalità: dovrebbe essere in grado di parcheggiare un'auto, rilasciare un'auto e riportare il numero di posti auto rimasti.
Crea una classe Car che rappresenti un'auto che può essere parcheggiata nel parcheggio.
Devi implementare quanto segue:
Una classe
Car, con un attributocar_id: dovrebbe essere fornito quando l'oggetto auto viene creato. Tutte le operazioni successive dovrebbero tenere conto delcar_id.Una classe
ParkingLotcon:total_spotsattribute: the total number of parking spots in the parking lot, which should be provided when the parking lot object is created.park(car)method: parks aCarobject in the parking lot. If the parking lot is full, it should printParking lot is full.release(car)method: releases aCarfrom the parking lot. If the car is not in the parking lot, it should printCar not found in the parking lot.spots_left()method: returns an integer representing the number of available parking spots in the parking lot.
Input | Output |
|---|---|
| 2 |
| 1 |
Constraints
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB