-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
67 lines (56 loc) · 2.35 KB
/
main.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
from flight_plan import FlightPlan
from airport_database import get_database, AirportDatabase
from aircraft_type import AircraftType
from route import Route
from altitude import Altitude
from airport import Airport
from airports import ewr, jfk, lga, phl
DATABASE = get_database()
SUPPORTED_AIRPORTS = ["KEWR", "KJFK", "KLGA", "KPHL"]
def get_departure(aircraft_type: AircraftType):
"""Prompts the user for their departure airport and checks if it's supported"""
while True:
departure = input("Please enter your departure airport's code (ICAO): ")
if departure in SUPPORTED_AIRPORTS:
break
print(f"{departure} is not a supported airport. Please choose one of the supported airports below:")
for airport in SUPPORTED_AIRPORTS:
print(airport)
if departure == "KEWR":
return ewr.EWR(aircraft_type)
if departure == "KJFK":
return jfk.JFK(aircraft_type)
if departure == "KLGA":
return lga.LGA(aircraft_type)
return phl.PHL(aircraft_type)
def get_arrival():
"""
Prompts the user for their arrival airport and checks if it is in the airport database (.dat file)
"""
while True:
arrival = input("Please enter your arrival airport's code (ICAO): ")
if DATABASE.is_in_list(arrival):
return arrival
if arrival == "0":
raise Exception("Unsupported arrival airport. User requested to exit")
print(f"{arrival} is not a supported arrival airport. It may be too small of an airport to be supported.")
print("Please enter a supported airport or type 0 to exit")
def main():
callsign = input("Please enter your callsign (in ICAO form): ") # No data validation necessary (it's just a callsign)
aircraft_type = AircraftType()
aircraft_type.get_aircraft_type()
departure = get_departure(aircraft_type)
arrival = get_arrival()
altitude = Altitude()
altitude.get_altitude()
altitude.check_altitude(departure.icao, arrival)
route = Route(departure, arrival)
route.get_route()
route.get_prd_route(altitude, aircraft_type)
departure.get_climb(str(route))
departure.get_initial()
altitude.alt = route.check_altitude(altitude)
route.check_dep_proc(departure)
plan = FlightPlan(callsign, departure, arrival, aircraft_type, route, altitude)
plan.get_clearance()
main()