class MainUI(): def __init__(self): self.airplaneui = AirplaneUI() self.destinationui = DestinationUI() self.employeeui = EmployeeUI() self.voyageui = VoyageUI() self.frame = Frame() def main_menu(self): """ Presents the user with the option to open any menu within the system """ action = "" while True: print("\tMain Menu") print() print('The following actions are possible:') print('\t1. Open Airplane Menu.') print('\t2. Open Destination Menu.') print('\t3. Open Employee Menu.') print('\t4. Open Voyage Menu.') print('Enter "q" to quit the program') action = input("Please enter your command: ") action = action.lower() self.frame.clear_all() if action == "1": self.airplaneui.airplane_menu() if action == "2": self.destinationui.destination_menu() if action == "3": self.employeeui.employee_menu() if action == "4": self.voyageui.voyage_menu() if action == "q": break
class VoyageUI(): def __init__(self): self.__ll_voyage = VoyageLL() self.__ll_destination = DestinationLL() self.__ui_destination = DestinationUI() self.__ll_employee = EmployeeLL() self.__ll_airplane = AirplaneLL() self.__voyage_list = list() self.frame = Frame() def voyage_menu(self): """ The user can choose between the create, change and display options in the system""" action = "" leave = "" while leave != "q": print("The following actions are possible: ") print("\tEnter 1 to create a voyage within the system.") print("\tEnter 2 to display voyages within the system.") print("\tEnter 3 to change voyage staff.") print("Enter b or q to got to the main menu.") action = input("Please enter your command: ").lower() self.frame.clear_all() if action == "1": leave = self.new_voyage() elif action == "2": print("Enter 1 to display a specific day.") action = input("Enter your command: ") if action == "b" or action == "q": break if action == "1": leave = self.show_by_status_day() elif action == "2": leave = self.show_all_of_employees_voyages() elif action == "3": leave = self.change_staff_on_voyage() if action == "q" or action == "b": break self.frame.clear_all() def new_voyage(self): """The user has chosen to create a new voyage""" action = "" new_voyage = "KEF," print('Enter "b" to go back and "q" to got to the main menu.') while True: self.__voyage_list = self.__ll_voyage.load_voyage_from_file() print(self.__voyage_list) print() date = input("Enter the departure time from Iceland (year(YYYY)/month(0-12)/day(0-31)/hour(0-23)/minutes(0-59): ") action = date if action.lower() == 'b': self.voyage_menu() if action.lower() == "q": return "q" self.frame.clear_all() while not self.__ll_voyage.validate_departure(action): print("Input is invalid!") action = input("Enter the departure time from Iceland (year(YYYY)/month(0-12)/day(0-31)/hour(0-23)/minutes(0-59): ") if action.lower() == 'b': self.voyage_menu() if action.lower() == "q": return "q" new_voyage += action + "," self.frame.clear_all() a = self.__ll_destination.load_destination_from_file() print(a) action = input("Enter the destination number: ") print() if action.lower() == 'b': self.voyage_menu() if action.lower() == "q": return "q" self.frame.clear_all() while not self.__ll_destination.check_if_exists(action,0): print("Input is invalid!") a= self.__ll_destination.load_destination_from_file() print(a) action = input("Enter the destination: ") print() if action.lower() == 'b': self.voyage_menu() if action.lower() == "q": return "q" new_voyage += action + "," self.frame.clear_all() available_list = self.__ll_airplane.check_if_available(date) print(available_list) plane_insignia = input("Enter the plane insignia of the airplane: ") action = plane_insignia print() if action.lower() == 'b': self.voyage_menu() if action.lower() == "q": return "q" self.frame.clear_all() while not self.__ll_airplane.check_if_in_available(date,action): print("Input is invalid!") plane_insignia = input("Enter the plane insignia of the airplane: ") action = plane_insignia print() if action.lower() == 'b': self.voyage_menu() if action.lower() == "q": return "q" new_voyage += action + "," self.frame.clear_all() a = self.__ll_employee.check_if_available(date,"captain") print(a) print() action = input("Enter the captain's SSN (0000000000): ") # User inputs the SSN for the captain if action.lower() == 'b': self.voyage_menu() if action.lower() == "q": return "q" self.frame.clear_all() while not self.__ll_employee.check_if_in_available(date,"captain",action): print("Input is invalid") a = self.__ll_employee.check_if_available(date,"captain") print(a) action = input("Enter the captain's SSN (0000000000): ") if action.lower() == 'b': self.voyage_menu() if action.lower() == "q": return "q" new_voyage += action + "," self.frame.clear_all() a = self.__ll_employee.check_if_available(date,"co-pilot") print(a) print() action = input("Enter the co-pilot's SSN (0000000000): ") # User inputs the SSN for the co-pilot if action.lower() == 'b': self.voyage_menu() if action.lower() == "q": return "q" self.frame.clear_all() while not self.__ll_employee.check_if_in_available(date,"co-pilot",action): print("Input is invalid") a = self.__ll_employee.check_if_available(date,"co-pilot") print(a) print() action = input("Enter the co-pilot's SSN (0000000000): ") if action.lower() == 'b': self.voyage_menu() if action.lower() == "q": return "q" new_voyage += action + "," self.frame.clear_all() a = self.__ll_employee.check_if_available(date,"flight service manager") print(a) print() action = input("Enter the flight service manager's SSN (0000000000): ") # User inputs the SSN for the fsm if action.lower() == 'b': self.voyage_menu() if action.lower() == "q": return "q" self.frame.clear_all() while not self.__ll_employee.check_if_in_available(date,"flight service manager",action): print("Input is invalid") a = self.__ll_employee.check_if_available(date,"flight service manager") print(a) print() action = input("Enter the flight service manager's SSN (0000000000): ") if action.lower() == 'b': self.voyage_menu() if action.lower() == "q": return "q" new_voyage += action + "," self.frame.clear_all() a = self.__ll_employee.check_if_available(date,"flight attendant") print(a) print() action = input("Enter the first flight attendant SSN (0000000000): ") # User inputs the SSN for the first flight attendant if action.lower() == 'b': self.voyage_menu() if action.lower() == "q": return "q" self.frame.clear_all() while not self.__ll_employee.check_if_in_available(date,"flight attendant",action): print("Input is invalid") action = input("Enter the first flight servant's SSN (0000000000): ") if action.lower() == 'b': self.voyage_menu() if action.lower() == "q": return "q" new_voyage += action + "," self.frame.clear_all() a = self.__ll_employee.check_if_available(date,"flight attendant") print(a) print() action = input("Enter the first flight attendant SSN (0000000000): ") # User inputs the SSN for the first flight attendant if action.lower() == 'b': self.voyage_menu() if action.lower() == "q": return "q" self.frame.clear_all() while not self.__ll_employee.check_if_in_available(date,"flight attendant",action): print("Input is invalid") action = input("Enter the first flight servant's SSN (0000000000): ") if action.lower() == 'b': self.voyage_menu() if action.lower() == "q": return "q" self.frame.clear_all() new_voyage += action self.__ll_voyage.create_voyage(new_voyage) action = input("Do you want to create another voyage? (y/n): ").lower() if action == "n": # virkar ekki! return "q" self.frame.clear_all() def display_menu(self): """After the user has chosen the "display" option, he has three new options""" action = "" leave = '' while leave != "q": print("\tEnter 1 for a daily list of voyages") print("\tEnter 2 for a list of flight numbers") print("\tEnter 3 to see the state of the voyages for today") print('Enter "b" to go back and "q" to got to the main menu.') action = input("Please enter your commmand: ").lower() self.frame.clear_all() if action == "1": action = self.daily_list() if action == "2": action = self.flight_numbers() if action == "3": action = self.daily_voyage_state() if action == 'b': self.voyage_menu() if action == 'q': return "q" def daily_list(self): """The user has chosen to have a list of voyages for a given day displayed""" action = "" display_voyages = "" print('Enter "b" to go back and "q" to got to the main menu.') self.frame.clear_all() while True: # ..og maður ýtir á q ferð maður bara til baka í voyage_menu...ekki main menu action = input("Enter a date: ") if action.lower() == 'b': self.voyage_menu() if action.lower() == "q": return "q" self.frame.clear_all() while not self.__ll_destination.validate_distance(action): # Nota distance núna því bara tölur MUNA :Breyta í DATETIME validated print("Input is invalid") action = input("Enter a date: ") if action == 'b': self.display_menu() if action.lower() == "q": return "q" display_voyages += action self.frame.clear_all() # Birta listannn ! # def flight_numbers(self): # """The user has chosen to have a list of flight numbers for a given date displayed""" # action = "" # display_numbers = "" # print('Enter "b" to go back and "q" to got to the main menu.') # fer líka bara til baka úr "Enter destination" í voyage menu með q # while True: # En þá er hægt að ýta aftur á q og þá fer maður í main menu... # action = input("Enter destination: ") # if action == 'b': # self.display_menu() # if action == 'q': # return "q" # while not self.__ll_destination.validate_country_name(action): # Sýna flugnúmer beggja flugferða þegar vinnuferðir eru listaðar. # print("Input is invalid") # action = input("Enter destination: ") # display_numbers += action # if action == 'b': # self.display_menu() # if action == 'q': # return "q" # action = input("Enter a date: ") # if action == 'b': # self.display_menu() # if action == 'q': # return "q" # while not self.__ll_destination.validate_distance(action): # Nota distance núna því bara tölur MUNA :Breyta í DATETIME validated # print("Input is invalid") # action = input("Enter a date: ") # display_numbers += action # if action == 'b': # self.display_menu() # if action == 'q': # return "q" # Birta lista flugnúmera fyrir innslegna dagsetningu def daily_voyage_state(self): """The user has chosen to have a list of voyage's status (finished, arrived or cancelled) displayed """ action = "" display_state = "" print('Enter "b" to go back and "q" to got to the main menu.') # Þegar maður er búinn að velja "see the state of the voyages.." og kemur "Enter date" .. # ..og maður ýtir á q ferð maður bara til baka í voyage_menu...ekki main menu action = input("Enter a date: ") # og ef maður velur b í Enter date og fer svo aftur inn og velur q þá fær maður input is invalid! if action == 'b': self.display_menu() if action == 'q': return "q" self.frame.clear_all() while not self.__ll_destination.validate_distance(action): # Nota distance núna því bara tölur MUNA :Breyta í DATETIME validated print("Input is invalid") action = input("Enter a date: ") if action == 'b': self.display_menu() if action == 'q': return "q" display_state += action # a) lokið, b) lent ytra, c) í loftinu eða d) ekki hafin self.frame.clear_all() # þarf að breyta strengnum í hlut, t.a.m. með dateutil.parser, # VANTAR Birta lista vinnuferða þar sem sést hvaða ferðum er lokið, lent ytra og eða felld niður def __str__(self): return_str = "" for voyage in self.__voyage_list: return_str += voyage.__str__() + '\n' return return_str self.frame.clear_all() def show_by_status_day(self): date = input("Please enter YYYY/mm/dd: ") if date.lower() == "b": self.voyage_menu() if date.lower() == "q": return "q" self.frame.clear_all() print() print(self.__ll_voyage.show_voyages_on_a_day(date)) action = input('Enter "b" to go back and "q" to got to the main menu: ') if action == "q": return "q" self.frame.clear_all() def show_all_of_employees_voyages(self): ssn = input("Enter the ssn of the employee (0000000000): ") if ssn == "b": self.display_menu if ssn == "q": return "q" while self.__ll_employee.check_if_ssn_exists(ssn): print("Invalid input! ") ssn = input("Enter the ssn of the employee(0000000000):") a = self.__ll_voyage.load_all_voyages(ssn) print(a) def change_staff_on_voyage(self)
class EmployeeUI(): def __init__(self): self.employeell = EmployeeLL() self.frame = Frame() def employee_menu(self): action = "" leave = '' while action != "b" and leave != "q": print("\tEmployee Menu") print() print('The following actions are possible:') print('\t1. Enter "1" to create a new employee within the system.') print( '\t2. Enter "2" to change employees already within the system.' ) print( '\t3. Enter "3" to display employees within the system by their status.' ) print( '\t4. Enter "4" to display employees within the system in alphabetical order.' ) print( "\t5. Enter '5' to display all flight attendants within the system. " ) print("\t6. Enter '6' to display all pilots within the system. ") print( "\t7. Enter '7' to display all pilots sorted by their permits. " ) print( "\t8. Enter '8' to display all information about a employee. ") print('Enter "b" to go back and "q" to got to the main menu.') action = input("Please enter your command: ") print() action = action.lower() self.frame.clear_all() if action == "1": leave = self.call_on_validate_and_create() elif action == "2": leave = self.call_on_validate_and_change() elif action == "3": leave = self.show_by_status() elif action == "4": leave = self.show_by_aplha() elif action == "5": leave = self.show_by_rank("flight attendant") elif action == "6": leave = self.show_by_rank("pilot") elif action == "7": leave = self.show_by_licence() elif action == "8": leave = self.show_a_single_employee() elif action == "b" or action == "q": break def call_on_validate_and_create(self): print('Enter "b" to go back and "q" to got to the main menu.') action = "" new_employee = "" self.frame.clear_all() while action.lower() != 'q': action = input("Enter the ssn: ") if action == 'b': break elif action == 'q': return 'q' while not self.employeell.validate_ssn(action): print("Input is invalid!") action = input("Enter the ssn: ") if action == 'b': break elif action == 'q': return 'q' self.frame.clear_all() new_employee += action + "," action = input("Enter the name: ") if action == 'b': break elif action == 'q': return 'q' self.frame.clear_all() while not self.employeell.validate_name(action): print("Input is invalid!") action = input("Enter the name: ") if action == 'b': break if action == 'q': return 'q' self.frame.clear_all() new_employee += action + "," action = input("Enter the address: ") if action == 'b': break elif action == 'q': return 'q' self.frame.clear_all() while not self.employeell.validate_address(action): print("input is invalid!") action = input("Enter the address") if action == 'b': break elif action == 'q': return 'q' new_employee += action + "," self.frame.clear_all() action = input("Enter the phone number: ") if action == 'b': break elif action == 'q': return 'q' self.frame.clear_all() while not self.employeell.validate_phone_number(action): print("Input is invalid!") action = input("Enter the phone number: ") if action == 'b': break elif action == 'q': return 'q' self.frame.clear_all() new_employee += action + "," action = input("Enter the user name: ") if action == 'b': break elif action == 'q': return 'q' self.frame.clear_all() while not self.employeell.validate_user_name(action): print("Input is invalid!") action = input("Enter the user name: ") if action == 'b': break if action == 'q': return 'q' new_employee += action + "," self.frame.clear_all() action = input( "Enter the rank (flight attendant, flight service manager, co-pilot or captain): " ) if action == 'b': break elif action == 'q': return 'q' self.frame.clear_all() while not self.employeell.validate_rank(action): print("Input is invalid!") action = input("Enter the rank: ") if action == 'b': break if action == 'q': return 'q' self.frame.clear_all() new_employee += action + "," action = input("Enter the permit, enter N/A if not appropriate: ") if action == 'b': break elif action == 'q': return 'q' self.frame.clear_all() while not self.employeell.validate_permit(action): print("Input is invalid!") action = input( "Enter the permit, enter N/A if not appropriate: ") if action == 'b': break if action == 'q': return 'q' self.frame.clear_all() new_employee += action self.employeell.add_employee(new_employee) action = input( "Do you want to create a new employee? (y)es or (n)o: ").lower( ) if action == "n": return "q" self.frame.clear_all() def call_on_validate_and_change(self): while True: employio = self.employeell.sort_employees_by_alpha() print(employio) print() ssn = input( "Please enter the SSN of the employee who's information you want to edit: " ) if ssn == "q": return "q" if ssn == "b": break print("Enter '1' to change the name. ") print("Enter '2' to change the address. ") print("Enter '3' to change the phone_number. ") print("Enter '4' to change the user_name. ") print("Enter 'q' to go back to the main menu") print("Enter 'b' to go back to the employee menu") action = input("Please enter your command: ") self.frame.clear_all() if action == "b": break elif action == "q": return "q" elif action == "1": change = "name" action = input( "please enter the new entry for {}: ".format(change)) if action == 'b': break elif action == 'q': return 'q' while not self.employeell.validate_name(action): print("input is invalid") action = input( "please enter the new entry for {}: ".format(change)) if action == 'b': break elif action == 'q': return 'q' self.frame.clear_all() elif action == "2": change = "address" action = input( "please enter the new entry for {}: ".format(change)) if action == 'b': break elif action == 'q': return 'q' while not self.employeell.validate_address(action): print("input is invalid") action = input( "please enter the new entry for {}: ".format(change)) if action == 'b': break elif action == 'q': return 'q' self.frame.clear_all() elif action == "3": change = "phone_number" action = input( "please enter the new entry for {}: ".format(change)) if action == 'b': break elif action == 'q': return 'q' self.frame.clear_all() while not self.employeell.validate_phone_number(action): print("input is invalid") action = input( "please enter the new entry for {}: ".format(change)) if action == 'b': break elif action == 'q': return 'q' self.frame.clear_all() elif action == "4": change = "user_name" action = input( "please enter the new entry for {}: ".format(change)) if action == 'b': break elif action == 'q': return 'q' self.frame.clear_all() while not self.employeell.validate_user_name(action): print("input is invalid") action = input( "please enter the new entry for {}: ".format(change)) if action == 'b': break elif action == 'q': return 'q' self.frame.clear_all() self.employeell.change_employee(ssn, change, action) action = input( "Do you want to change another employee? (y)es or (n)o: " ).lower() if action == "n": return "q" self.frame.clear_all() def show_by_status(self): a = input("Please enter YYYY/mm/dd: ") if a == "b": self.employee_menu() if a == "q": return "q" print() b = self.employeell.show_by_status(a) print(b) action = input( 'Enter "b" to go back and "q" to got to the main menu: ') if action == "q": return "q" self.frame.clear_all() def show_by_aplha(self): print() employio = self.employeell.sort_employees_by_alpha() print(employio) print() action = input( 'Enter "b" to go back and "q" to got to the main menu: ') if action == "q": return "q" self.frame.clear_all() def show_by_rank(self, rank): print() if rank == "pilot": employio = self.employeell.display_pilots("alpha") print(employio) print() action = input( 'Enter "b" to go back and "q" to got to the main menu: ') if action == "q": return "q" if rank == "flight attendant": a = self.employeell.show_flight_atendants() print(a) print() action = input( 'Enter "b" to go back and "q" to got to the main menu: ') if action == "q": return "q" self.frame.clear_all() def show_a_single_employee(self): employio = self.employeell.sort_employees_by_alpha() print(employio) ssn = input("enter the ssn of the employee you want to see: ") if ssn == 'b': self.employee_menu() elif ssn == 'q': return 'q' self.frame.clear_all() while not self.employeell.check_for_ssn(ssn): print("Invalid input!") ssn = input("Enter the ssn: ") if ssn == 'b': self.employee_menu() if ssn == 'q': return 'q' self.frame.clear_all() employio = self.employeell.show_single_employee(ssn) print(employio) print() action = input( 'Enter "b" to go back and "q" to got to the main menu: ') if action == "q": return "q" self.frame.clear_all() def show_by_licence(self): print() employio = self.employeell.display_pilots("permit") print(employio) print() action = input( 'Enter "b" to go back and "q" to got to the main menu: ') if action == "q": return "q" self.frame.clear_all()
class AirplaneUI: def __init__(self): self.airplanell = AirplaneLL() self.frame = Frame() def airplane_menu(self): ''' Presents the user with every interaction for "airplane_menu". ''' action = "" leave = '' while leave != "q": print("\tAirplane Menu") print() print('The following actions are possible:') print('\t1. enter "1" to create a new plane within the system.') print('\t2. enter "2" to display pilots with a specific licence') print('\t3. enter "3" to display planes within the system.') print('\t4. enter "4" to display planes by their status.') print('Enter "b" to go back and "q" to got to the main menu.') action = input("Please enter your command: ") print() action = action.lower() self.frame.clear_all() if action == "1": leave = self.call_on_validate_and_create() if action == "2": leave = self.show_pilots_by_airplane_type() if action == "3": leave = self.show() if action == "4": leave = self.show_by_status() if action == "b" or action == "q": break def call_on_validate_and_create(self): """ Asks the user for input for each object required in """ print('Enter "b" to go back and "q" to got to the main menu.') action = "" new_plane = "" while True: action = input("Enter the manufacturer: ").upper() if action == "B": self.airplane_menu() elif action == "Q": return 'q' self.frame.clear_all() while not self.airplanell.validate_manufacturer(action): print("Input is invalid!") action = input("Enter the manufacturer: ").upper() if action == "B": self.airplane_menu() elif action == "Q": return 'q' new_plane += action + "," self.frame.clear_all() action = input("Enter the type ID: ").upper() if action == "B": self.airplane_menu() elif action == "Q": return 'q' self.frame.clear_all() while not self.airplanell.validate_typeID(action): print("Input is invalid!") action = input("Enter the type ID: ").upper() if action == "B": self.airplane_menu() elif action == "Q": return 'q' new_plane += action + "," self.frame.clear_all() action = input("Enter the plane insignia: ").upper() if action == "B": self.airplane_menu() elif action == "Q": return 'q' self.frame.clear_all() while not self.airplanell.validate_plane_insignia(action): print("Input is invalid!") action = input("Enter the plane insignia: ").upper() if action == "B": self.airplane_menu() elif action == "Q": return 'q' new_plane += action + "," self.frame.clear_all() action = input("Enter the model: ").upper() if action == "B": self.airplane_menu() elif action == "Q": return 'q' self.frame.clear_all() while not self.airplanell.validate_model(action): print("Input is invalid!") action = input("Enter the model: ").upper() if action == "B": self.airplane_menu() elif action == "Q": return 'q' new_plane += action self.frame.clear_all() self.airplanell.create_plane(new_plane) action = input( "Do you want to create another airplane? (y)es or (n)o: " ).lower() if action == "n": return "q" self.frame.clear_all() def show_pilots_by_airplane_type(self): ''' Presents the user with every pilot with the selected flight license ''' airio = self.airplanell.load_from_file() print(airio) type_id = input("By what plane type do you want to search? ") if type_id == "b": return if type_id == "q": return "q" self.frame.clear_all() employio = self.airplanell.display_by_licence(type_id) print(employio) print() action = input( 'Enter "b" to go back and "q" to got to the main menu: ') if action == "q": return "q" self.frame.clear_all() def show(self): ''' Presents the user with every plane within the system ''' airio = self.airplanell.load_from_file() print(airio) print() action = input( 'Enter "b" to go back and "q" to got to the main menu: ') if action == "q": return "q" self.frame.clear_all() def show_by_status(self): pass
class DestinationUI: def __init__(self): self.__ll_destination = DestinationLL() self.frame = Frame() def destination_menu(self): ''' Presents the user with ''' leave = "" while leave != "q": print("\tDestination Menu") print() print("The following actions are possible:") print( '\t1. Enter "1" to create a new destination within the system.' ) print('\t2. Enter "2" to change a destinations emergency contact.') print('\t3. Enter "3" to display destinations within the system.') print() action = input("Please enter your command: ") action = action.lower() self.frame.clear_all() if action == "1": leave = self.add_destination() elif action == "2": leave = self.change_contact() elif action == "3": leave = self.display_destination() elif action == "b" or action == "q": break def add_destination(self): """The user has chosen to create a new destination""" print("Destinations within the systems: ") carl = self.__ll_destination.load_destination() print(carl) print('Enter "b" to go back and "q" to got to the main menu.') action = "" # User puts in the name of the country destination = "" self.frame.clear_all() while True: action = input("Enter destination number: ") if action == 'b': break # en svo kemur "please enter your command" og þá virkar q rétt if action == 'q': return "q" self.frame.clear_all() while self.__ll_destination.check_if_exists(action, 0): print("Input is invalid!") action = input("Enter destination number: ").upper() if action == 'b': break # en svo kemur "please enter your command" og þá virkar q rétt if action == 'q': return "q" self.frame.clear_all() destination += action + "," carl = self.__ll_destination.load_destination() print(carl) action = input("Enter the destination name: ") print() if action == 'b': self.destination_menu() if action == 'q': return "q" self.frame.clear_all() while not self.__ll_destination.validate_destination_name(action): print("Input is invalid!") carl = self.__ll_destination.load_destination() print(carl) action = input("Enter the destination name: ") print() if action.lower() == 'b': self.destination_menu() if action.lower() == 'q': return "q" self.frame.clear_all() destination += action + "," action = input("Enter destination id: ") if action == 'b': self.destination_menu() if action == 'q': return "q" self.frame.clear_all() while not self.__ll_destination.validate_destination_id(action): print("Input is invalid") action = input("Enter destination id: ") if action.lower() == "b": self.destination_menu() if action.lower() == "q": return "q" self.frame.clear_all() destination += action + "," action = input("Enter country name: " ) # Þarf að laga: q virkar bara eins og b hér if action.lower() == 'b': break # en svo kemur "please enter your command" og þá virkar q rétt if action.lower() == 'q': return "q" self.frame.clear_all() while not self.__ll_destination.validate_country_name(action): print("Input is invalid!") action = input("Enter country name: ") if action.lower() == 'b': break if action.lower() == 'q': return "q" self.frame.clear_all() destination += action + "," action = input( "Enter airport: ") # User puts in the name of the airport if action.lower() == 'b': break if action.lower() == 'q': return "q" self.frame.clear_all() while not self.__ll_destination.validate_airport_name( action): # velja flugvöll ? print("Input is invalid!") action = input("Enter airport: ").upper() if action == 'b': return if action == 'q': return "q" if action == 'b': break destination += action + "," self.frame.clear_all() action = input("Enter flight-time (hours.minutes): " ) # User puts in the flight time if action == 'b': break if action == 'q': return "q" self.frame.clear_all() while not self.__ll_destination.validate_flight_time(action): print("Input is invalid!") action = input("Enter flight-time(hours.minutes): ") if action == 'b': break if action == 'q': return "q" self.frame.clear_all() destination += action + "," action = input("Enter distance from Iceland: ") if action.lower() == 'b': break if action.lower() == 'q': return "q" self.frame.clear_all() while not self.__ll_destination.validate_distance(action): print("Input is invalid!") action = input("Enter distance from Iceland in km: ") if action.lower() == 'b': break if action.lower() == 'q': return "q" self.frame.clear_all() destination += action + "km" + "," action = input("Enter name of emergency contact: ") if action.lower() == 'b': break if action.lower() == 'q': return "q" self.frame.clear_all() while not self.__ll_destination.validate_contact_name(action): print("Input is invalid!") action = input("Enter name of emergency contact: ") if action.lower() == 'b': break if action.lower() == 'q': return "q" self.frame.clear_all() destination += action + "," # User puts in the phone number of the emergency contact action = input("Enter emergency contact's phone number: ") if action.lower() == 'b': break if action.lower() == 'q': return "q" self.frame.clear_all() while not self.__ll_destination.validate_contact_number(action): print("Invalid input") action = input("Enter emergency contact's phone number: ") if action.lower() == 'b': break if action.lower() == 'q': return "q" destination += action self.frame.clear_all() self.__ll_destination.create_destination(destination) action = input( "Do you want to enter another destination? (y/n): ").lower() if action == "y": # virkar continue if action == "n": # virkar ekki! return "q" self.frame.clear_all() def change_contact(self): """ The user has chosen to change the name and/or phone number of the emergency contact""" action = "" contact = "" print('Enter "b" to go back and "q" to got to the main menu.' ) # q virkar bara eins og b while True: print() carl = self.__ll_destination.load_destination() print(carl) action = input("Enter the contact's destination ID: ").upper( ) # The user inputs the location of the emergency contact if action.lower() == 'b': break if action.lower() == 'q': return "q" self.frame.clear_all() while self.__ll_destination.check_if_exists(action, 2): print("Invalid input") carl = self.__ll_destination.load_destination() print(carl) action = input("Enter the contact's destination ID: ").upper() if action == 'b': break elif action == 'q': return "q" self.frame.clear_all() if action == 'b': break contact = action print("Enter 1 to change the name of the emergency contact") print("Enter 2 to change the emergency contact's phone number") action = input("Please enter you command: ") self.frame.clear_all() if action == "1": change = "emergency contact" new = input( "Please enter the new entry for {}: ".format(change)) self.frame.clear_all() while not self.__ll_destination.validate_contact_name(new): print("Input is invalid!") new = input( "Please enter the new entry for {}:".format(change)) self.frame.clear_all() elif action == "2": change = "emergency phone" new = input( "Please enter the new entry for {}: ".format(change)) self.frame.clear_all() while not self.__ll_destination.validate_contact_number(new): print("Input is invalid!") new = input( "Please enter the new entry for {}: ".format(change)) self.frame.clear_all() elif action == 'b': break elif action == 'q': return "q" self.__ll_destination.change_destination(contact, change, new) action = input( "Do you want to change another employee? (y)es or (n)o: " ).lower() if action == "n": return "q" self.frame.clear_all() def display_destination(self): ''' Calls for "load_destination_from_file" from "Destination_UI.py" to display every destination within the system. ''' print() carl = self.__ll_destination.load_destination() print(carl) action = input( 'Enter "b" to go back and "q" to got to the main menu: ') if action == "q": return "q" self.frame.clear_all()