/
tower.py
87 lines (72 loc) · 3.33 KB
/
tower.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from Aircraft import *
class Tower:
__flightClearance = False
flightList = ["0001a", '0001b', '0001c', '0001d', '0001e']
flightNum = ""
__fuelCheck = False
# Testing airplane codes are correct and adding them to a list of correct codes.
# Codes can be added also.
def __init__(self):
self.anAirplane = Aircraft()
def currentFlightList(self):
for plane in self.flightList:
print(plane)
def updateFlightList(self, flightNum):
# testing new flight codes are of correct format
while True:
if len(flightNum) == 5:
if flightNum not in self.flightList:
print("Flight code", flightNum, "does not appear to be on our system.")
self.add_to_system = input("Do you wish to be added to the updated system?")
else:
print("Flight code", flightNum, " is in our system.")
break
if self.add_to_system == "y":
self.flightList.append(flightNum)
self.currentFlightList()
break
else:
print("Flight number not added to system.")
break
# Checks flight codes are correct.
def checkFlightList(self):
print("")
while True:
for plane in self.flightList:
print(plane)
check = input("Flight list check correct?")
if check == "y":
print("Flight list authorization complete.")
break
else:
removeFlight = input("Enter flight number that you wish to remove:")
if removeFlight in self.flightList:
self.flightList.remove(removeFlight)
print("Flight number", removeFlight, "was deleted from flight list system.")
else:
print("Invalid flight number entered.")
print("Please enter a authorized flight code.")
def requestFlightCheck(self):
self.anAirplane.flightNum = input("Enter flight number: ")
if len(self.anAirplane.flightNum) == 5:
if self.anAirplane.flightNum not in self.flightList:
print("Flight code", self.anAirplane.flightNum, "does not appear to be on our system.")
self.add_to_system = input("Do you wish to be added to the updated system?")
if self.add_to_system == "y":
self.flightList.append(self.anAirplane.flightNum)
self.currentFlightList()
else:
print("Flight number not added to system.")
else:
# Create anAirplane object and grant clearance
print("Flight code", self.anAirplane.flightNum, "is in our system.")
#check fuel
self.anAirplane.fuelCheck()
if self.__fuelCheck == False:
print("Refueling in process .. ")
self.anAirplane.addFuel(15000)
self.anAirplane.__flightClearance = self.anAirplane.fuelCheck()
self.anAirplane.preFlightCheck()
else:
self.anAirplane.__flightClearance = self.anAirplane.fuelCheck()
self.anAirplane.preFlightCheck()