コード例 #1
0
    def __show_all_airplane_types():
        ComponentUI.print_header(AirplanesUI.__FRAME_IN_USE_STR)
        print(TextEditor.format_text("All airplane types", TextEditor.UNDERLINE_TEXT))
        user_input = ""

        

        while user_input not in AirplanesUI.__NAVIGATION_BAR_OPTIONS:
            table_header_tuple = ("Type", "Manufacturer", "Seats")
                  
           
            airplane_type_list = LogicAPI.get_all_airplane_types()
            airplanes_type_getfunctions_tuple = ([aircraft_type.get_plane_type() for aircraft_type in airplane_type_list],[aircraft_type.get_manufacturer() for aircraft_type in airplane_type_list],\
                [aircraft_type.get_seat_count() for aircraft_type in airplane_type_list])
            table_height = len(airplane_type_list)

            ### - ONLY DISPLAY TABLE - ##

            ComponentUI.fill_in_table(table_header_tuple, airplanes_type_getfunctions_tuple, False)
            ComponentUI.fill_window_and_print_action_line(table_height+2) 


            #ComponentUI.print_frame_table_menu(table_header_tuple, airplanes_type_getfunctions_tuple, table_height, ComponentUI.print_header(AirplanesUI.__FRAME_IN_USE_STR),"All airplane types")
            user_input = ComponentUI.get_user_input()
            user_input = ComponentUI.remove_brackets(user_input)
            if not user_input.isdigit() or int(user_input) > table_height:
                    continue
            table_index = int(user_input)-1
            airplane = airplane_type_list[table_index]        

            user_input = AirplanesUI.__show_airplane(airplane)

        return user_input
コード例 #2
0
    def __show_airplanes_in_use():
        LogicAPI.update_states() #UPDATES ALL STATES BEFOR DISPLAYING


        ComponentUI.print_header(AirplanesUI.__FRAME_IN_USE_STR)
        print(TextEditor.format_text("All airplanes in use", TextEditor.UNDERLINE_TEXT))
        user_input = ""
        while user_input not in AirplanesUI.__NAVIGATION_BAR_OPTIONS:
            table_header_tuple = ("Name", "State", "Type", "Manufacturer", "Seats")
            airplanes_list = LogicAPI.get_all_airplanes_in_use()
            if airplanes_list:
                airplanes_getfunctions_tuple = ([airplane.get_name() for airplane in airplanes_list],[airplane.get_state() for airplane in airplanes_list],\
                [airplane.get_type() for airplane in airplanes_list], [airplane.get_manufacturer() for airplane in airplanes_list], [airplane.get_seat_count() for airplane in airplanes_list])
                table_height = len(airplanes_list)
                ComponentUI.print_frame_table_menu(table_header_tuple,airplanes_getfunctions_tuple, table_height, AirplanesUI.__FRAME_IN_USE_STR, "All airplanes in use")
                user_input = ComponentUI.get_user_input()
                user_input = ComponentUI.remove_brackets(user_input)
                if not user_input.isdigit() or int(user_input) > table_height:
                    continue
                table_index = int(user_input)-1
                airplane = airplanes_list[table_index]        

                user_input = AirplanesUI.__show_airplane(airplane)
            else:
                ComponentUI.print_header(AirplanesUI.__FRAME_IN_USE_STR)
                print(TextEditor.format_text("All airplanes in use", TextEditor.UNDERLINE_TEXT))
                ComponentUI.centered_text_message("There are no airplanes in use at the moment !","",3)

           
            return user_input
コード例 #3
0
    def __show_employee_voyages(employee):
        is_pilot = isinstance(employee, Pilot)

        user_input = ""

        info_header_tuple = ("Destination", "Airplane name", "Start time",
                             "End time", "State")

        while user_input not in EmployeeUI.__NAVIGATION_BAR_OPTIONS:
            ComponentUI.print_header(EmployeeUI.__FRAME_IN_USE_STR)
            print(
                TextEditor.format_text(
                    "Voyages for {}".format(employee.get_name()),
                    TextEditor.UNDERLINE_TEXT))

            ComponentUI.fill_window_and_print_action_line(1)

            user_input = input("Insert a week number: ").strip()

            if not user_input:
                continue

            voyages_list = []

            if user_input.isdigit():
                voyages_list = LogicAPI.get_all_pilot_voyages_in_a_week(employee, int(user_input)) if is_pilot\
                    else LogicAPI.get_all_flight_attendant_voyages_in_a_week(employee ,int(user_input))

            if not voyages_list:
                ComponentUI.print_header(EmployeeUI.__FRAME_IN_USE_STR)
                print(
                    TextEditor.format_text("Find employees voyages",
                                           TextEditor.UNDERLINE_TEXT))
                ComponentUI.centered_text_message(
                    "Could not find a voyage going for {} in week {}".format(
                        employee.get_name(), user_input), "", 3)

                return ComponentUI.get_user_input()

            else:
                voyage_info_tuple = ([voyage.get_flights()[0].get_arrival_location() for voyage in voyages_list],\
                [voyage.get_airplane().get_name() for voyage in voyages_list],\
                [voyage.get_schedule()[0] for voyage in voyages_list],\
                [voyage.get_schedule()[1] for voyage in voyages_list],\
                [voyage.get_state() for voyage in voyages_list])

                table_height = len(voyages_list)
                ComponentUI.print_frame_table_menu(info_header_tuple, voyage_info_tuple, \
                    table_height, ComponentUI.print_header(EmployeeUI.__FRAME_IN_USE_STR),"Voyages for {}".format(employee.get_name()))
                user_input = ComponentUI.get_user_input()
                user_input = ComponentUI.remove_brackets(user_input)
                if not user_input.isdigit() or int(user_input) > table_height:
                    continue
                table_index = int(user_input) - 1
                voyage = voyages_list[table_index]
                user_input = VoyageUI.show_voyage(voyage)

            return user_input
コード例 #4
0
    def __show_pilot_by_license_finder():
        LogicAPI.update_states()  #UPDATES ALL STATES BEFOR DISPLAYING

        user_input = ""

        info_header_tuple = ("Name", "SSN", "Phone number", "Home address",
                             "E-mail", "State")

        while user_input not in EmployeeUI.__NAVIGATION_BAR_OPTIONS:
            ComponentUI.print_header(EmployeeUI.__FRAME_IN_USE_STR)
            #display table of airplane types and return the type-name the of chosen one , head above the the table
            user_input = EmployeeUI.__airplane_type_picker(
                "Find pilots by license")

            if not user_input:
                continue

            user_input = user_input

            pilots_list = []

            pilots_list = LogicAPI.get_licensed_pilots(user_input)

            ComponentUI.print_header(EmployeeUI.__FRAME_IN_USE_STR)

            if not pilots_list:
                print(
                    TextEditor.format_text("Find pilots by license",
                                           TextEditor.UNDERLINE_TEXT))
                ComponentUI.centered_text_message(
                    "Could not find a pilot with a license for {}".format(
                        user_input), "", 3)
                user_input = ComponentUI.get_user_input()
                if not user_input:
                    return EmployeeUI.__show_pilot_by_license_finder()

                return user_input

            else:
                #print(TextEditor.format_text("Pilots with license for " + user_input, TextEditor.UNDERLINE_TEXT))
                pilot_info_tuple = ([pilot.get_name() for pilot in pilots_list],[pilot.get_ssn() for pilot in pilots_list],\
                [pilot.get_phonenumber() for pilot in pilots_list],[pilot.get_home_address() for pilot in pilots_list],[pilot.get_email() for pilot in pilots_list],\
                [pilot.get_state() for pilot in pilots_list])
                table_height = len(pilots_list)
                ComponentUI.print_frame_table_menu(
                    info_header_tuple, pilot_info_tuple, table_height,
                    EmployeeUI.__FRAME_IN_USE_STR,
                    "Pilots with license for " + user_input)
                user_input = ComponentUI.get_user_input()
                user_input = ComponentUI.remove_brackets(user_input)
                if not user_input.isdigit() or int(user_input) > table_height:
                    continue
                table_index = int(user_input) - 1
                employee = pilots_list[table_index]

                user_input = EmployeeUI.__show_employee(employee)

            return user_input
コード例 #5
0
    def show():
        ''' Displaying the Quit confirmation message '''
        user_input = ""
        while not user_input.startswith('n'):

            ComponentUI.print_header(ComponentUI.get_main_options()[4])
            QuitUI.__print_quit_menu_body()

            user_input = ComponentUI.get_user_input()
            user_input = ComponentUI.remove_brackets(user_input)

            if user_input.startswith('y'):
                Window.clear()
                raise SystemExit

        return "Back to main menu"
コード例 #6
0
    def __show_employees_off_duty():
        LogicAPI.update_states()  #UPDATES ALL STATES BEFOR DISPLAYING

        ComponentUI.print_header(EmployeeUI.__FRAME_IN_USE_STR)
        print(
            TextEditor.format_text("All employees off duty",
                                   TextEditor.UNDERLINE_TEXT))
        user_input = ""
        while user_input not in EmployeeUI.__NAVIGATION_BAR_OPTIONS:
            table_header_tuple = ("Name", "SSN", "Phone number",
                                  "Home address", "E-mail", "State")
            employees_off_duty_list = LogicAPI.get_employees_off_duty()
            if employees_off_duty_list:
                employees_off_duty_value_tuple = ([employees_off_duty.get_name() for employees_off_duty in employees_off_duty_list],[employees_off_duty.get_ssn() for employees_off_duty in employees_off_duty_list],\
                [employees_off_duty.get_phonenumber() for employees_off_duty in employees_off_duty_list], [employees_off_duty.get_home_address() for employees_off_duty in employees_off_duty_list],\
                [employees_off_duty.get_email() for employees_off_duty in employees_off_duty_list], [employees_off_duty.get_state() for employees_off_duty in employees_off_duty_list])
                table_height = len(employees_off_duty_list)
                ComponentUI.print_frame_table_menu(
                    table_header_tuple, employees_off_duty_value_tuple,
                    table_height, EmployeeUI.__FRAME_IN_USE_STR,
                    "All employees off duty")
                user_input = ComponentUI.get_user_input()
                user_input = ComponentUI.remove_brackets(user_input)
                if not user_input.isdigit() or int(user_input) > table_height:
                    continue
                table_index = int(user_input) - 1
                employee_off_duty = employees_off_duty_list[table_index]

                user_input = EmployeeUI.__show_employee(employee_off_duty)

            else:
                ComponentUI.print_header(EmployeeUI.__FRAME_IN_USE_STR)
                print(
                    TextEditor.format_text("Employees off duty",
                                           TextEditor.UNDERLINE_TEXT))

                ComponentUI.centered_text_message(
                    "No employee is off duty at the moment", "", 3)
                user_input = ComponentUI.get_user_input()

            return user_input
コード例 #7
0
    def show():
        ''' Displaying message on the center of when program is opened '''
        ComponentUI.print_header()
        MainMenuUI.__print_main_menu_body()

        return ComponentUI.get_user_input()
コード例 #8
0
    def __show_employee_by_name_finder():
        LogicAPI.update_states()  #UPDATES ALL STATES BEFOR DISPLAYING

        user_input = ""

        info_header_tuple = ("Job title", "Name", "SSN", "Phone number",
                             "Home address", "E-mail", "State")

        while user_input not in EmployeeUI.__NAVIGATION_BAR_OPTIONS:
            ComponentUI.print_header(EmployeeUI.__FRAME_IN_USE_STR)
            print(
                TextEditor.format_text("Find employee by name or ssn",
                                       TextEditor.UNDERLINE_TEXT))

            ComponentUI.fill_window_and_print_action_line(1)

            user_input = input("Insert name or ssn: ").strip()

            employees = []

            if not user_input:
                continue

            #If he enters  a digit
            if user_input.isdigit():
                if '-' in user_input:
                    user_input = user_input.replace('-', '')
                if ' ' in user_input:
                    user_input = user_input.replace(' ', '')

                employees = LogicAPI.get_employee_by_ssn(user_input)

                ComponentUI.print_header(EmployeeUI.__FRAME_IN_USE_STR)
                print(
                    TextEditor.format_text("Find employee by name or ssn",
                                           TextEditor.UNDERLINE_TEXT))

                if not employees:
                    ComponentUI.centered_text_message(
                        "No employee found with the ssn: {}".format(
                            user_input), "", 3)

                    return ComponentUI.get_user_input()

                else:
                    employee_info_tuple =  (["Pilot" if isinstance(employee, Pilot) else "Flight attendant" for employee in employees], [employee.get_name() for employee in employees],[employee.get_ssn() for employee in employees],\
                    [employee.get_phonenumber() for employee in employees],[employee.get_home_address() for employee in employees],[employee.get_email() for employee in employees],\
                    [employee.get_state() for employee in employees])

                    table_height = len(employees)
                    ComponentUI.print_frame_table_menu(
                        info_header_tuple, employee_info_tuple, table_height,
                        EmployeeUI.__FRAME_IN_USE_STR, "Employee")
                    user_input = ComponentUI.get_user_input()
                    user_input = ComponentUI.remove_brackets(user_input)
                    if not user_input.isdigit() or int(
                            user_input) > table_height:
                        continue
                    table_index = int(user_input) - 1
                    employee = employees[table_index]

                    user_input = EmployeeUI.__show_employee(employee)

                return user_input
            else:
                name_list = []
                for name in user_input.split():
                    name_list.append(name.capitalize())

                user_input = " ".join(name_list)

                employees = LogicAPI.get_employee_by_name(user_input)

                ComponentUI.print_header(EmployeeUI.__FRAME_IN_USE_STR)
                print(
                    TextEditor.format_text("Find employee by name or ssn",
                                           TextEditor.UNDERLINE_TEXT))

                if not employees:

                    ComponentUI.centered_text_message(
                        "Could not find an employee named {}".format(
                            user_input), "", 3)

                    return ComponentUI.get_user_input()

                else:
                    employee_info_tuple =  (["Pilot" if isinstance(employee, Pilot) else "Flight attendant" for employee in employees], [employee.get_name() for employee in employees],[employee.get_ssn() for employee in employees],\
                    [employee.get_phonenumber() for employee in employees],[employee.get_home_address() for employee in employees],[employee.get_email() for employee in employees],\
                    [employee.get_state() for employee in employees])
                    table_height = len(employees)
                    ComponentUI.print_frame_table_menu(
                        info_header_tuple, employee_info_tuple, table_height,
                        EmployeeUI.__FRAME_IN_USE_STR, "Employee")
                    user_input = ComponentUI.get_user_input()
                    user_input = ComponentUI.remove_brackets(user_input)
                    if not user_input.isdigit() or int(
                            user_input) > table_height:
                        continue
                    table_index = int(user_input) - 1
                    employee = employees[table_index]

                    user_input = EmployeeUI.__show_employee(employee)

                return user_input