def __init__(self): self.employeeUI = EmployeeUI() self.destinationUI = DestinationUI() self.voyageUI = VoyageUI() self.airplaneUI = AirplaneUI() super().__init__()
def startDisplayAirplaneType(self): '''Menu for displaying airplane types''' success = False airplane_types = AirplaneUI().getAirplaneTypes() while True: print( '\nWhat type would you like to list? Please choose one of the following:' ) counter = 1 for airplane_type in airplane_types: print('{} - {}'.format(counter, airplane_type)) counter += 1 selection = input('\nPlease choose one of the above: ').strip() for i in range(1, counter + 1): if selection == str(i): planeTypeId = airplane_types[i - 1].getplaneTypeID() success = True return AirplaneUI().showAirplanesByType(planeTypeId) if not success: print('\nInvalid selection!\n')
def startDisplayAirplanes(self): '''Main display for airplanes''' print() print('-'*45) print('{:^45}'.format('DISPLAY - Airplanes')) print('-'*45) print() while True: print('What would you like to display?') print('-'*45) print('1 - List all airplanes') print('2 - List all airplane types and number of licensed pilots') print('3 - List airplanes by type') print('4 - List airplanes by date and time') print('m - Back to main menu') selection = input('\nPlease choose one of the above: ').strip() #Prints all airplanes owned by NaN Air if selection == '1': return AirplaneUI().showAllPlanes() elif selection == '2': return AirplaneUI().showAllAirplaneTypes() # Prints all airplanes that are a certain type, type is chosen on next screen elif selection == '3': return DisplayMenuAirplaneType().startDisplayAirplaneType() # Gets availability status on airplanes at an inputted date elif selection == '4': print('\nEnter the date you want to display') year_str = input('Year: ').strip() month_str = input('Month: ').strip() day_str = input('Day: ').strip() hour_str = input('Hour: ').strip() minute_str = input('Minute: ').strip() # check if date input is valid year_int,month_int,day_int = LL_API().verifyDate(year_str,month_str,day_str) # checks if time input is valid hour_int,minute_int = LL_API().verifyTime(hour_str,minute_str) # get datetime object of inputted time datetime_object = datetime.datetime(year_int,month_int,day_int,hour_int,minute_int) return AirplaneUI().showAirplanesByDateTime(datetime_object) #Goes back to main menu elif selection == 'm': return # If none of the possibilities are chosen else: print('Invalid selection!') print()
def startSubMenuRegister(self): # Header print() print('#' * 45) print('{:^45}'.format('REGISTER')) print('#' * 45) print() while True: print('-' * 45) print('{:^45}'.format('What would you like to do?')) print('-' * 45) print() print('1 - Add new Employee') print('2 - Add new Voyage') print('3 - Add new Airplane with an existing type') print('4 - Add new Airplane Type') print('5 - Add new Destination') print('m - Main menu') print() selection = input('Please choose one of the above: ').strip() if selection == '1': # Add new employee return CrewUI().addCrew() elif selection == '2': # Add new voyage return VoyageUI().addVoyage() elif selection == '3': # Add new Airplane return AirplaneUI().addAirplane() elif selection == '4': return AirplaneUI().addAirplaneType() elif selection == '5': # Add new destination return DestinationUI().addDestination() elif selection == 'm': # Back to main menu return else: print("\nInvalid selection!\n")
def addAircraftToVoyage(self, voyage): '''Adds aircraft to voyage''' depart_datetime_object = self.revertDatetimeStrtoDatetime( voyage.getDepartureTime()) arrival_datetime_object = self.revertDatetimeStrtoDatetime( voyage.getArrivalTimeHome()) print() aircraft_ID = AirplaneUI().getAirplaneInput(depart_datetime_object, arrival_datetime_object) voyage.setAircraftID(aircraft_ID) print('\n' + '~' * 45) print('Airplane has been added to voyage {}'.format( voyage.getVoyageID())) print('~' * 45 + '\n') return LL_API().change_voyage(voyage)
def startDisplayLicensedPilots(self): '''Display menu for licensed pilots''' success = False airplane_types = AirplaneUI().getAirplaneTypes() while True: print('\nPlease pick one license of the following:\n') counter = 1 for airplane_type in airplane_types: print('{} - {}'.format(counter, airplane_type)) counter += 1 selection = input('\nPlease choose one of the above: ').strip() for i in range(1, counter + 1): if selection == str(i): license_ID = airplane_types[i - 1].getplaneTypeID() success = True return CrewUI().showByLicense(license_ID) if not success: print('\nInvalid selection!\n')
class User(Page): def __init__(self): self.employeeUI = EmployeeUI() self.destinationUI = DestinationUI() self.voyageUI = VoyageUI() self.airplaneUI = AirplaneUI() super().__init__() def Home(self): options = ["1. Staff manager", "2. Planning manager", "3. Exit"] self.show_page(options) user_input = input().strip() chose_back = False while not chose_back: self.first_pick = user_input if user_input == "1": # Staff manager chose_back = self.Staff_manager() elif user_input == "2": # Planning manager chose_back = self.Planning_manager() elif user_input == "3": # Exit # Return "True" to end the outside loop (in this case the loop in the main program) return True else: # Invalid input self.valid = False return False return False #Continue outside loop def Staff_manager(self): """ Displays the option screen for a staff manager. Options: Man flights, lists of work force and manage work force """ header = "Staff manager" options = [ "1. Man flights", "2. Workforce information", "3. Manage workforce", "4. Back" ] self.show_page(options, header) user_input = input().strip() chose_back = False while not chose_back: if user_input == "4": # Back # return "True" so the loop displaying the screen ends. return True elif user_input == "1": # Man flights chose_back = self.voyageUI.man_voyage_SM() elif user_input == "2": # Workforce information chose_back = self.Workforce_information() elif user_input == "3": # Manage workforce chose_back = self.manage_workforce() else: # Invalid input # set valid to false to display an error message self.valid = False return False # Return "False" to display this screen again return False def manage_workforce(self): header = "Manage workforce" options = [ "1. Register a new airplane", "2. Register a new employee", "3. Edit employee", "4. Back" ] self.show_page(options, header) user_input = input().strip() chose_back = False if not chose_back: if user_input == "4": # Back return True elif user_input == "1": # Register new airplane chose_back == self.airplaneUI.register_airplane() elif user_input == "2": # Register a new employee chose_back == self.employeeUI.register_employee() elif user_input == "3": # Edit employee chose_back == self.employeeUI.edit_employee() else: # Invalid input self.valid = False return False return False def Planning_manager(self): header = "Planning manager" options = [ "1. Manage voyages", "2. Voyage informations", "3. Manage destinations", "4. Back" ] self.show_page(options, header) user_input = input().strip() chose_back = False if not chose_back: if user_input == "4": # Back return True elif user_input == "1": # Manage voyages chose_back = self.manage_voyages() elif user_input == "2": # Voyage information chose_back = self.list_of_voyages() elif user_input == "3": # Manage destinations chose_back = self.manage_destinations() else: # Invalid input # set valid to false to display a "... valid input..." message self.valid = False return False return False def manage_voyages(self): header = "Manage voyages" options = [ "1. Register a new voyage", "2. Edit a voyage", "3. Cancel a voyage", "4. Back" ] self.show_page(options, header) voyage_pick = input().strip() chose_back = False if not chose_back: if voyage_pick == "4": # Back return True elif voyage_pick == "1": # Register a new voyage chose_back = self.voyageUI.register_voyage_PM() elif voyage_pick == "2": # Edit a voyage chose_back = self.edit_voyage_information() elif voyage_pick == "3": # Cancel a voyage chose_back = self.voyageUI.cancel_voyage() else: self.valid = False return False return False def edit_voyage_information(self): edit_header = "Edit voyage" edit_options = [ "1. Edit voyage date", "2. Edit destination", "3. Back" ] self.show_page(edit_options, edit_header) user_input_str = input().strip() chooseBack = False if not chooseBack: if user_input_str == "1": # edit voyage date chooseBack = self.voyageUI.edit_voyage_date() elif user_input_str == "2": # edit destination """ þarf að klára """ chooseBack == self.destinationUI.edit_destination() elif user_input_str == "3": chooseBack == True else: self.valid = False return True def list_of_voyages(self): options = [ "1. List all voyages", "2. List by day", "3. List by week", "4. Back" ] self.show_page(options) user_input = input().strip() chose_back = False if not chose_back: if user_input == "4": return True elif user_input == "1": chose_back = self.voyageUI.print_all_voyages() elif user_input == "2": chose_back = self.voyageUI.list_voyage_day() elif user_input == "3": chose_back = self.voyageUI.print_list_voyage_by_week() else: self.valid = False return False return False def manage_destinations(self): header = "Manage destinations" options = [ "1. Voyage repetions", "2. Edit contact information", "3. Register destination", "4. Back " ] self.show_page(options, header) user_input = input().strip() chose_back = False while not chose_back: if user_input == "4": return True elif user_input == "1": True elif user_input == "2": chose_back = self.destinationUI.edit_destination() elif user_input == "3": chose_back = self.destinationUI.register_destination( ) # Endalaus loopa else: self.valid = False return False return False def Workforce_information(self): header = "Workforce information" options = [ "1. List of all airplanes", "2. List of all employees", "3. List of all flight attendants", "4. List of all pilots", "5. List of all available employees at a given time", "6. List of all busy employees at a given time", "7. Print week of employee", "8. Back" ] self.show_page(options, header) user_input = input().strip() chose_back = False while not chose_back: if user_input == "8": return True elif user_input == "1": chose_back = self.airplaneUI.list_all_airplanes() elif user_input == "2": chose_back = self.employeeUI.get_all_employees( ) # Endalaus loopa elif user_input == "3": chose_back = self.employeeUI.list_all_flight_attendants( ) # Endalaus loopa elif user_input == "4": chose_back = self.employeeUI.list_all_pilots( ) # Endalaus loopa elif user_input == "5": chose_back = self.employeeUI.available_employees( ) # Festist inní elif user_input == "6": chose_back = self.employeeUI.busy_employees() # Festist inní elif user_input == "7": chose_back = self.employeeUI.print_week_of_employee( ) # Festist hérna inni, ekki hægt að fara til baka else: self.valid = False return False return False
def addVoyage(self): '''Gets input from user to add voyage to file''' print('\n' + '-' * 45) print('{:^45}'.format('Add new voyage')) print('-' * 45) dest = self.getDest() # put selection as 2 so while loop is entered selection = '2' # while user chooses to redo input while selection == '2': # get datetime input departure_datetime = self.getDateWithTime() print('Are you sure you want to add this voyage?') print('-' * 45) print('1 - Confirm input') print('2 - Redo input') print('3 - Cancel voyage registration') print() selection = input('Please choose one of the above: ').strip() print() # if user confirms input if selection == '1': while True: if departure_datetime != None: # arrival time found from departure time arrival_time = LL_API().getArrivalTime( departure_datetime, dest) # if date is taken by another voyage while LL_API().checkIfTakenDate( departure_datetime) == True: print( 'Another voyage is departing or arriving at that time. Please choose another date.' ) departure_datetime = self.getDateWithTime() if departure_datetime != 'c': continue else: return print( 'Would you like to assign an airplane to this voyage?') print('(You can also do this later)') selection = input( 'Input your selection (Y/N): ').lower().strip() # while input is neither y or n while selection != 'y' and selection != 'n': selection = input( 'Please enter Y or N to make your choice: ').lower( ).strip() # if chosen to add airplane if selection == 'y': plane_name = AirplaneUI().getAirplaneInput( departure_datetime, arrival_time) # if chosen to add airplane later else: plane_name = 'empty' LL_API().add_voyage(dest, departure_datetime, plane_name) print() print('~' * 45) print('{:^45}'.format('New voyage succesfully added!')) print('~' * 45) return else: departure_datetime = self.getDateWithTime() continue # user cancels registration elif selection == '3': return # if nothing else is chosen else: print('\nInvalid input!\n')