Esempio n. 1
0
    def getAirplaneInput(self, departure_datetime, arrival_datetime):
        '''Shows a list of available airplanes and gets 
        airplane input from the user'''

        print('Available airplanes at time of departure:')
        print()

        # Gets a list of available planes
        airplanes_list = LL_API().showPlanesForNewVoyage(
            departure_datetime, arrival_datetime)
        print('{:<10}{:<15}'.format('Insignia', 'Type'))
        print('-' * 25)

        for plane in airplanes_list:
            print('{:<10} {:<15}'.format(plane.get_planeInsignia(),\
                    plane.get_planeTypeID()))

        plane_name = input(
            '\nEnter Insignia of the plane (TF-XXX): ').upper().strip()

        # Checks if an airplane already exists
        check = LL_API().checkPlaneInput(plane_name, airplanes_list)

        while check == False:
            print('\n' + '-' * 45)
            print('{:^45}'.format('This plane is not available on this date'))
            print('{:^45}'.format('please choose one of the listed planes.'))
            print('-' * 45 + '\n')

            plane_name = input('Please try again: ').upper().strip()
            check = LL_API().checkPlaneInput(plane_name, airplanes_list)

        return plane_name
Esempio n. 2
0
    def removeAirplaneFromVoyage(self, voyage):
        ''' Removes airplane from voyage, staff assigned to the voyage 
            will be removed '''

        old_airplane_type = voyage.getAircraftID()
        crew_members_counter = self.countCrewmembers(voyage)

        if crew_members_counter > 0:
            success = self.removeAirplaneFromVoyageWithStaff(
                voyage, crew_members_counter)
            if success:
                voyage.removeAirplaneFromVoyage()
                voyage.removeCrewFromVoyage()
                LL_API().change_voyage(voyage)
            else:
                return

        else:
            voyage.removeAirplaneFromVoyage()

            LL_API().change_voyage(voyage)

        print('\n' + '~' * 45)
        a_str = 'Airplane {} has been'.format(old_airplane_type)
        b_str = 'removed from voyage {}'.format(voyage.getVoyageID())
        print('{:^45}'.format(a_str))
        print('{:^45}'.format(b_str))
        print('~' * 45 + '\n')
Esempio n. 3
0
    def changeEmergencyContactPhoneNumber(self):
        '''Changes emergency contact phone number'''

        print()
        airport_code = input(
            'Enter airport code (IATA - 3 letters): ').upper().strip()

        # Verifies if the airport code is valid
        check = LL_API().checkDestInput(airport_code)

        while check == False:
            print('Please enter a valid destination!')
            airport_code = input(
                'Enter airport code (IATA - 3 letters): ').upper().strip()
            # Verifies if the airport code is valid
            check = LL_API().checkDestInput(airport_code)

        # Gets new emergency phone number and verifies the input at the same time
        new_emergency_phone = self.getDestinationEmergencyPhoneNumber()
        destination_instance = self.getOneDestination(airport_code)
        destination_instance.setEmergencyContactPhone(new_emergency_phone)

        LL_API().changeEmergencyContact(destination_instance)

        print('\nNew Emergency Phone Number ({}) for {} has been saved.\n'.
              format(new_emergency_phone,
                     destination_instance.getDestinationName()))
Esempio n. 4
0
    def getDest(self):
        '''Gets user input for a 3 letter destination code'''

        # all destinations
        destinations_class_list = LL_API().get_destinations()
        print()
        print('Please choose a destination.')
        print('Available destinations are:')
        print(45 * '-')

        # print destinations with 3 letter IATA code
        for destination in destinations_class_list:
            if destination.getDestinationAirport() != 'KEF':
                print('\t{:<3}: {:<10}'.format(destination.getDestinationName(),\
                    destination.getDestinationAirport()))

        print()
        dest = input('Your destination (3 letters): ').upper().strip()

        # check if input is valid
        check = LL_API().checkDestInput(dest)

        # while input is not valid
        while check == False:
            dest = input('Please enter a valid destination: ').upper().strip()
            check = LL_API().checkDestInput(dest)

        return dest
Esempio n. 5
0
    def showNotWorkingCrew(self, date_str):
        '''Gets a list of all crew not working on a certain date inputted by user'''

        # Str turned into datetime
        datetime_object = LL_API().revertDatetimeStrtoDatetime(date_str)
        # Instance list of all crew not working
        not_working_crew_list = LL_API().get_not_working_crew(datetime_object)
        self.printCrew(not_working_crew_list, False)
Esempio n. 6
0
    def showAllVoyagesInRange(self, start_datetime='', end_datetime=''):
        '''Shows all voyages for a current time period'''

        if start_datetime == '':
            print('\nEnter start date for time period')
            print()
            start_datetime = VoyageUI().getDateInput()

        if end_datetime == '':
            print('\nEnter end date for time period')
            print()
            end_datetime = VoyageUI().getDateInput()

        completed_voyages_in_range = LL_API().getCompletedVoyagesInRange(
            start_datetime, end_datetime)

        voyages_on_date = LL_API().get_all_voyages_in_date_range(
            start_datetime, end_datetime)
        start_date = VoyageUI().seperateDatetimeString(
            start_datetime.isoformat())[0]
        end_date = VoyageUI().seperateDatetimeString(
            end_datetime.isoformat())[0]

        if voyages_on_date != []:
            print()
            print('All voyages from {} to {}'.format(start_date, end_date))
            print(60 * VoyageUI.SEPERATOR)

            for voyage in voyages_on_date:

                crew_on_voyage_list = voyage.getCrewOnVoyage()

                flight_no_out, flight_no_home = voyage.getFlightNumbers()

                voyage_duration_hrs, voyage_duration_min = \
                    LL_API().get_voyage_duration(voyage)

                voyage_state = self.getStatusOfVoyage(voyage)

                if VoyageUI.EMPTY in crew_on_voyage_list[0:3]:
                    # not fully staffed if there is not one captain, one pilot and
                    # one flight attendant
                    voyage_staffed = 'Voyage not staffed'
                elif VoyageUI.EMPTY in crew_on_voyage_list[-2:]:
                    voyage_staffed = 'Voyage has enough staff'
                else:
                    voyage_staffed = 'Voyage fully staffed'

                aircraft_ID = voyage.getAircraftID().upper()


                VoyageUI().prettyprint(voyage,voyage_staffed,aircraft_ID,\
                    voyage_duration_hrs, flight_no_out, flight_no_home, \
                        voyage_duration_min, voyage_state)

            return voyages_on_date, completed_voyages_in_range
        else:
            return None
Esempio n. 7
0
    def showWorkingCrew(self, date_str):
        '''Gets a list of all crew working on a certain date and lists them'''

        # Str turned into datetime
        datetime_object = LL_API().revertDatetimeStrtoDatetime(date_str)
        # Instance list of all working crew members
        working_crew_list = LL_API().get_working_crew(datetime_object)
        # Send info to be printed
        self.printCrew(working_crew_list, True)
Esempio n. 8
0
    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()
Esempio n. 9
0
    def addCrewToVoyage(self, voyage):
        '''Adds crew to a voyage'''

        airplane = LL_API().getAirplanebyInsignia(voyage.getAircraftID())
        airplane_type_on_voyage = airplane.get_planeTypeID()

        crew_on_voyage_list = voyage.getCrewOnVoyage()

        if 'empty' in crew_on_voyage_list[0:3]:
            print()
            CrewUI().showQualifiedCrew(voyage.getDepartureTime(),
                                       voyage.getAircraftID())
            print('You must add 1 captain and 1 copilot with license for {} and 1 head flight attendant'\
                .format(airplane_type_on_voyage))
            print(95 * '-')
            print()

            while 'empty' in crew_on_voyage_list[0:3]:
                # Captain, copilot and head flight attendant must be added added at the same time
                # Voyage must have captain, copilot and head flight attendant

                crew_member = CrewUI().queryShowNotWorkingCrew()
                if crew_member:
                    self.checkRank(crew_member, voyage,
                                   airplane_type_on_voyage)
                    crew_on_voyage_list = voyage.getCrewOnVoyage()

                else:
                    break

            if crew_member:
                LL_API().change_voyage(voyage)
                print('~' * 70)
                print('A captain, pilot and head flight attendant have been added to voyage {}\n'\
                    .format(voyage.getVoyageID()))
                print('~' * 70)
                AddExtraCrewmemberMenu().startAddExtraCrewMenu(
                    voyage, crew_on_voyage_list)

            else:
                return

        elif 'empty' in crew_on_voyage_list:
            # If captain, copilot and head flight attendant are assigned to voyage the
            # option to add extra flight attendant is presented
            print()

            AddExtraCrewmemberMenu().startAddExtraCrewMenu(
                voyage, crew_on_voyage_list)

        else:
            print('\nVoyage is fully staffed!\n')
            # If voyage is fully staffed no more crewmembers can be added
            return
Esempio n. 10
0
    def showAllAirplaneTypes(self):
        '''Shows all airplane types and the number of 
        pilots that have a license for that type'''

        airplane_type_dict = LL_API().showAirplaneTypes()

        print()
        print('{:<20}{:<10}'.format('Airplane Type',
                                    'Number of Licensed Pilots'))
        print('-' * 45)

        for key, value in airplane_type_dict.items():
            print('{:<20}{:>15}'.format(key, value))

        print('-' * 45)
Esempio n. 11
0
    def getDestinationAirport(self):
        '''Gets destination airport code from user'''

        while True:
            destination_airport = input(
                'Destination airport code (3char airport code): ').upper(
                ).strip()

            # Checks if the destination already exists
            check = LL_API().checkDestInput(destination_airport)

            if check == False:
                for letter in destination_airport:
                    # The airport code can't contain
                    # digits or a punctuation
                    if letter.isdigit() or letter in string.punctuation:
                        print('\nInvalid airport code!\n')
                        break
                else:
                    if len(destination_airport) == 3:
                        return destination_airport
                    else:
                        print('\nInvalid airport code\n')
            else:
                print('\nDestination already exists!\n')
Esempio n. 12
0
    def addAirplaneType(self):
        '''Gets information about a new airplane
        type and adds it to the file'''
        print()
        print('-' * 45)
        print('{:^45}'.format('Please fill in the following information.'))
        print('-' * 45)
        print()
        planeTypeId = input('Enter plane type id: ').strip()
        manufacturer = input('Enter manufacturer: ').strip()
        model = input('Enter model: ').strip()
        capacity = self.getNumberOfSeats()
        emptyWeight = self.getEmptyWeight()
        maxTakeoffWeight = self.getMaxTakeOffWeight()
        unitThrust = self.getUnitThrust()
        serviceCeiling = self.getServiceCeiling()
        length = self.getLength()
        height = self.getHeight()
        wingspan = self.getWingspan()

        LL_API().addAirplaneType(planeTypeId,manufacturer,model,capacity,\
            emptyWeight,maxTakeoffWeight,unitThrust,serviceCeiling,length,height,wingspan)

        print()
        print('~' * 45)
        print('{:^45}'.format('Airplane type successfully added!'))
        print('~' * 45)
Esempio n. 13
0
    def showAllDestinations(self):
        '''Shows all destinations of NanAir'''

        # Gets a list of all destination instances
        destinations = LL_API().get_destinations()

        print('\n' + '-' * 45)
        print('{:^45}'.format('All destinations'))
        print('-' * 45)

        header_str = '\n{:<15}{:<15}{:<10}{:<12}{:<20}{:<12}'.format(
            'Airport Code', 'Destination', 'Duration', 'Distance',
            'Emergency Contact ', 'Phone Number')
        print(header_str)
        print('-' * len(header_str))

        # Go through all destination instances and print them
        for destination in destinations:
            dest = destination.getDestinationName()
            code = destination.getDestinationAirport()
            distance = destination.getDestinationDistance()
            contact = destination.getDestinationContact()
            emergency_phone_number = destination.getDestinationEmergencyPhoneNumber(
            )
            duration = destination.getDestinationDuration()

            format_str = '{:<15}{:<15}{:<10}{:<12}{:<15}{:>12}'.format(
                code, dest, duration, distance, contact,
                emergency_phone_number)

            print(format_str)

        print('\n\n')
Esempio n. 14
0
    def removeCrewFromVoyage(self, voyage):
        ''' Removes all crewmembers from voyage'''

        crew_members_counter = self.countCrewmembers(voyage)

        if crew_members_counter == 0:
            # if no crewmembers are assinged they can not be removed
            print('\n' + 45 * '-')
            print('No crewmembers are assigned to the voyage!')
            print(45 * '-' + '\n')
        else:
            print('-' * 45)
            print('{:^45}'.format('Are you sure you want to'))
            print('{:^45}'.format('remove all crew members?'))
            print('-' * 45 + '\n')
            print('1 - Yes\n2 - No (Go back)\n')
            selection = input('Please choose one of the above: ').strip()
            if selection == '1':
                voyage.removeCrewFromVoyage()
                LL_API().change_voyage(voyage)
                print('~' * 45)
                print('{:^45}'.format('All crewmembers have been removed!'))
                print('~' * 45 + '\n')

            elif selection == '2':
                return
            else:
                print('\nInvalid selection!\n')
Esempio n. 15
0
    def getPilotLicense(self):
        '''Gets pilot license from user '''
        success = False

        # List of plane type instances
        airplane_types = LL_API().loadAirplaneTypes()

        print('-' * 45)
        print('{:^45}'.format('Please choose one of the following'))
        print('{:^45}'.format('Pilot licenses:'))
        print('-' * 45)
        print()

        while True:
            # Counter is used to show which buttons the user can press
            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):
                # Pilot license found from input
                if selection == str(i):
                    pilot_license = airplane_types[i - 1].getplaneTypeID()
                    success = True
                    return pilot_license

            if not success:
                print('\nInvalid selection!\n')
Esempio n. 16
0
    def changeEmployeeInfo(self, employee):
        '''Sends changed instance into LL layer'''

        LL_API().changeCrewInfo(employee)
        print('\n' + '~' * 45)
        print('{:^45}'.format('Employee info has been updated!'))
        print('~' * 45 + '\n')
Esempio n. 17
0
    def showCrew(self):
        ''' Shows full list of crew, pilots and flight attendants'''

        # List of instances of all crew members
        crew = LL_API().get_crew()
        string = ''

        print(CrewUI.pilot_header)

        for employee in crew:
            # Name and ID appended to string
            string = '{:<40}{:<20}'.format(employee.getName(),
                                           employee.getCrewID())

            # Role appended to string, if employee is pilot license is also appended
            if type(employee) == Pilot:
                if employee.getBool():
                    string += '{:<25}{:<10}'.format('Captain',
                                                    employee.getLicense())
                else:
                    string += '{:<25}{:<10}'.format('Co-pilot',
                                                    employee.getLicense())
            else:
                if employee.getBool():
                    string += '{:<15}'.format('Head service manager')
                else:
                    string += '{:<15}'.format('Flight attendant')

            print(string)

        print()
Esempio n. 18
0
    def checkIfCrewmemberWorking(self, voyage, crew_member):
        '''Checks if crewmember is working on the day of the voyage'''

        voyage_departuredate_str = voyage.getDepartureTime()
        voyage_departure_datetime = LL_API().revertDatetimeStrtoDatetime(
            voyage_departuredate_str)

        voyage_arrivaldate_str = voyage.getArrivalTimeHome()
        voyage_arrival_datetime = LL_API().revertDatetimeStrtoDatetime(
            voyage_arrivaldate_str)

        voyages_on_date = LL_API().get_all_voyages_in_date_range(
            voyage_departure_datetime, voyage_arrival_datetime)

        for voyage in voyages_on_date:
            if crew_member.getCrewID() in voyage.getCrewOnVoyage():
                return True
Esempio n. 19
0
    def getOneDestination(self, dest_code):
        '''Gets one destination by destination code '''

        all_destinations = LL_API().get_destinations()

        for destination in all_destinations:
            if destination.getDestinationAirport() == dest_code:
                return destination
        else:
            return None
Esempio n. 20
0
    def checkCompleted(self):
        '''Gets an voyage id as an input and checks if the voyage is completed'''

        while True:
            voyage_id = input("Enter voyage ID to select: ").strip()

            # class instance of voyage with inputted ID
            voyage = LL_API().getOneVoyage(voyage_id)
            if voyage:
                # get status of voyage (completed, not departed, in air)
                voyage_state = LL_API().get_status_of_voyage(voyage)
                if voyage_state == 'Completed':
                    print('-' * 45 + '\n')
                    print('{:^45}'.format('Voyage is completed'))
                    print('\n' + '-' * 45)

                    return voyage
                else:
                    return voyage
            else:
                print('\nNo voyage with this ID\n')
Esempio n. 21
0
    def addAirplane(self):
        '''Gets information about a new airplane
           and adds it to the file'''

        planeInsignia = self.getAirplaneInsigniaInput()
        planeTypeID, manufacturer, seats = self.getPlaneTypeIDInput()

        LL_API().addAirplane(planeInsignia, planeTypeID, manufacturer, seats)
        print()
        print('~' * 45)
        print('{:^45}'.format('Airplane successfully added!'))
        print('~' * 45)
Esempio n. 22
0
    def showAirplanesByDateTime(self, date_str):
        '''Shows airplanes availability by a date and time'''

        # Gets a tuple of available airplanes list and not available airplane list
        # Returns None if all airplanes are available
        airplane_tuple = LL_API().showAirplanesByDateTime(date_str)
        header_str = '{:<15}{:<15}{:<15}{:<15}{:<20}{:<25}{:<15}'.format('PlaneInsignia',\
            'planeTypeId','Seats','Flight Number','Availability',\
                'Available again','Destination')
        print()
        print(header_str)
        print('-' * len(header_str))

        if airplane_tuple != None:
            not_available_airplanes_list, available_airplanes_list = airplane_tuple
            # Prints all available airplanes
            for airplane in available_airplanes_list:
                format_str = '{:<15}{:<15}{:<15}{:<15}{:<20}{:<25}{:<15}'.format(airplane.get_planeInsignia(),\
                    airplane.get_planeTypeID(),airplane.get_planeCapacity(),\
                        'N/A','Available','N/A','N/A')
                print(format_str)

            # Prints all not available airplanes
            for airplane, destination, arrival_time, flight_number in not_available_airplanes_list:
                format_str = '{:<15}{:<15}{:<15}{:<15}{:<20}{:<25}{:<15}'.format(airplane.get_planeInsignia(),\
                    airplane.get_planeTypeID(),airplane.get_planeCapacity(),\
                        flight_number,'Not available',arrival_time,destination)
                print(format_str)

            print()

        else:
            # All airplanes are available if there's no voyage on the date
            airplanes_list = LL_API().showAllPlanes()
            for airplane in airplanes_list:
                format_str = '{:<15}{:<15}{:<15}{:<15}{:<20}{:<25}{:<15}'.format(airplane.get_planeInsignia(),\
                    airplane.get_planeTypeID(),airplane.get_planeCapacity(),\
                        'N/A','Available','N/A','N/A')
                print(format_str)
            print()
Esempio n. 23
0
    def showQualifiedCrew(self, depart_time_str, plane_insignia):
        '''Prints a list of crew that can be assigned to new voyage'''

        # Get list of instances of all crew qualified to fly a certain type of aircraft
        qualified_crew_list = LL_API().getQualifiedCrew(
            depart_time_str, plane_insignia)

        if qualified_crew_list != None:
            self.printCrew(qualified_crew_list, False)
        else:
            print(
                'There are no non-working staff qualified to fly this plane. Please pick another one.'
            )
Esempio n. 24
0
    def isPilotOnFutureVoyage(self, pilot):
        '''Checks if pilot instance is working on other voyages in the future. If he is, 
        a list of the IDs for the voyages he is working on is returned.'''
        voyage_id_with_pilot = []

        # all future voyages
        upcoming_voyage_list = LL_API().get_upcoming_voyages()
        for voyage in upcoming_voyage_list:
            if pilot.getCrewID() in voyage.getCrewOnVoyage(
            ):  # if pilot is assigned to a voyage
                voyage_id_with_pilot.append(voyage.getVoyageID())

        return voyage_id_with_pilot
Esempio n. 25
0
    def prettyprint(self,voyage,voyage_staffed,aircraft_ID,voyage_duration_hrs,\
                flight_no_out, flight_no_home, voyage_duration_min, voyage_state):
        '''Prints out a voyage'''
        print('\n' + '-' * 50)
        # destination
        print('To {}, {} on {} at {}'.format(voyage.getDestination().getDestinationName(),\
            voyage.getDestination().getDestinationAirport(),\
                voyage.getDepartureTime()[:10] ,voyage.getDepartureTime()[-8:-3]))
        print('-' * 50)

        # status
        print('\t Status: {}'.format(voyage_state))

        print('\t Flight numbers: {} - {}'.format(flight_no_out,
                                                  flight_no_home))

        # if aircraft is assigned
        if aircraft_ID != 'EMPTY' and aircraft_ID != 'empty':
            airplane = LL_API().getAirplanebyInsignia(aircraft_ID)
            aircraft_type = airplane.get_planeTypeID()
            total_seats = airplane.get_planeCapacity()
            sold_seats_out, sold_seats_home = voyage.getSeatsSold()
            print('\t Seats sold on flight {}: {}/{}'.format(flight_no_out,\
                sold_seats_out,total_seats))
            print('\t Seats sold on flight {}: {}/{}'.format(flight_no_home,\
                sold_seats_home,total_seats))
            print('\t Aircraft: {}, type {}'.format(aircraft_ID,
                                                    aircraft_type))
        elif aircraft_ID == 'EMPTY' or aircraft_ID == 'empty':
            print('\t Aircraft: No aircraft assigned to voyage')

        print('\t Total time: {} hrs {} min'.format(voyage_duration_hrs,\
            voyage_duration_min))

        print('\t Status on staff: {}'.format(voyage_staffed))
        print('\t Voyage ID: {}'.format(voyage.getVoyageID()))

        print('-' * 50)
Esempio n. 26
0
    def showSchedule(self, crew_ID):
        ''' Shows the schedule for a specific crew member '''

        employee = LL_API().get_crew_member_by_id(crew_ID)

        if employee != None:

            start_year_str, start_month_str, start_day_str = self.getDateInput(
                'start')

            start_year_int, start_month_int, start_day_int = LL_API(
            ).verifyDate(start_year_str, start_month_str, start_day_str)
            start_date = datetime.datetime(start_year_int, start_month_int,
                                           start_day_int, 0, 0,
                                           0)  #VERIFY INPUT

            end_year_str, end_month_str, end_day_str = self.getDateInput('end')

            end_year_int, end_month_int, end_day_int = LL_API().verifyDate(
                end_year_str, end_month_str, end_day_str)
            end_date = datetime.datetime(end_year_int, end_month_int,
                                         end_day_int, 0, 0, 0)  # VERIFY INPUT

            work_schedule_list = LL_API().get_work_schedule(
                start_date, end_date, crew_ID)

            name_header_str = '{:^45}\n{:^45}'.format(employee.getName(),
                                                      'ID:' + crew_ID)
            date_str = '{}.{}.{}-{}.{}.{}'.format(\
                start_day_int,start_month_int,start_year_int,end_day_int,end_month_int,end_year_int)
            header_str = '{:^45}\n{:^45}'.format('Working Schedule', date_str)

            print('\n' + '-' * 45)
            print(name_header_str)
            print(header_str)
            print(45 * '-' + '\n')

            if work_schedule_list != None:
                for voyage in work_schedule_list:
                    flight_no_out, flight_no_home = voyage.getFlightNumbers()
                    voyage_duration_hrs, voyage_duration_min = LL_API(
                    ).get_voyage_duration(voyage)
                    aircraft_ID = voyage.getAircraftID()
                    self.prettyprint(voyage,flight_no_out,flight_no_home,voyage_duration_hrs,voyage_duration_min,\
                    aircraft_ID)
                return True
            else:
                print('No voyages in this time period\n')
                return True
        else:
            return False
Esempio n. 27
0
    def getDateInput(self):
        '''Gets a date input from the user and returns a datetime object'''

        year_str = input('Year: ').strip()
        month_str = input('Month: ').strip()
        day_str = input('Day: ').strip()

        # check if date is valid
        year_int, month_int, day_int = LL_API().verifyDate(
            year_str, month_str, day_str)

        # turn date input into datetime object
        datetime_input = datetime.datetime(year_int, month_int, day_int, 0, 0,
                                           0)
        return datetime_input
Esempio n. 28
0
    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)
Esempio n. 29
0
 def changeSoldSeats(self, voyage, a_str):
     '''Changes sold seats on a given flight route in a voyage'''
     while True:
         print('\nEnter number of seats sold')
         print('m - to go back\n')
         new_seats_str = input('Enter your input: ').strip()
         if new_seats_str == 'm':
             return
         elif new_seats_str.isdigit():
             LL_API().changeSoldSeats(voyage, a_str, new_seats_str)
             print('-' * 45 + '\n')
             print('{:^45}'.format(
                 'Number of sold seats successfully changed!'))
             print('\n' + '-' * 45)
             return
         else:
             print('\nInvalid input!')
    def startEditExistingVoyage(self):
        '''Menu for editing existing voyages'''
        while True:
            print('\n' + '-' * 45)
            print('{:^45}'.format('Edit existing voyage menu'))
            print('-' * 45)
            print('1 - Enter voyage ID')
            print('2 - See a list of voyages on a specific time range')
            print('m - Back to edit menu')
            print()
            selection = input('Please choose one of the above: ').strip()
            print()

            # voyage found by entering voyage
            if selection == '1':
                # check if voyage was in the past and cannot be changed
                voyage = VoyageUI().checkCompleted()
                voyage_state = LL_API().get_status_of_voyage(voyage)

                if voyage_state != 'Completed':
                    # print info on voyage
                    VoyageUI().showOneVoyage(voyage)

            # voyage found by viewing all voyages during an inputted time frame
            elif selection == '2':
                print('Select date range to find a voyage to edit')
                voyage = VoyageUI().checkVoyagesInRange()
                if voyage:
                    VoyageUI().showOneVoyage(voyage)
                    print()
                else:
                    return

            elif selection == 'm':
                # goes back to main menu
                return

            else:
                # if none of the possible options was chosen
                print('Invalid selection!\n')
                voyage = None

            if voyage:
                # voyage instance sent to editing menu
                ChangeOneVoyageMenu(voyage).startChangeOneVoyageMenu()