-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.py
52 lines (42 loc) · 1.61 KB
/
commands.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
def park_new_car(parking_lot, registration_no, colour):
if parking_lot is None:
return 'Parking lot not initialized'
else:
return parking_lot.park_new_car(registration_no, colour)
def car_departure(parking_lot, slot_number):
if parking_lot is None:
return 'Parking lot not initialized'
# Case when slot_number is not present in the parking lot
elif slot_number > parking_lot.get_parking_lot_size():
return 'No such parking lot'
else:
return parking_lot.car_departure(slot_number)
def get_status(parking_lot):
if parking_lot is None:
print('Parking lot not initialized')
return
res = parking_lot.get_status()
print("Slot No. Registration No Colour")
for s, r, c in res:
print("{:<12}{:<19}{}".format(s, r, c))
def get_registration_by_colour(parking_lot, colour):
if parking_lot is None:
return 'Parking lot not initialized'
res = parking_lot.registration_numbers_for_cars_with_colour(colour)
if len(res) == 0:
return "No {0} cars are parked".format(colour)
else:
return res
def get_slot_by_colour(parking_lot, colour):
if parking_lot is None:
return 'Parking lot not initialized'
res = parking_lot.slot_numbers_for_cars_with_colour(colour)
if len(res) == 0:
return "No {0} cars are parked".format(colour)
else:
return res
def get_slot_by_registration(parking_lot, registration_no):
if parking_lot is None:
return 'Parking lot not initialized'
else:
return parking_lot.slot_number_for_registration_number(registration_no)