Ejemplo n.º 1
0
class DestinationLL():
    ''' DestinationLL class has methods that performs methods offered in the destination user interface'''
    def __init__(self):
        self.mainObject = MainIO()

    def addNewDestination(self, newDestination):
        return self.mainObject.addNewDestIO(newDestination)
        
    def getDestination(self):
        return self.mainObject.getDestinationsIO()
    
    def getDestinationByID(self, country):
        destinationObjectList = self.mainObject.getDestinationsIO()
        for destination in destinationObjectList:
            if destination.getCountry == country:
                return destination
        
    def updateDestination(self, dataList):
        return self.mainObject.updateDestIO(dataList)

    def generadeDestinationId(self):
        ''' When creating a destination we call this method to generate the id'''
        destinationObjectList = self.mainObject.getDestinationsIO()
        destinationID_list = []
        for destID in destinationObjectList:
           destinationID_list.append(destID.getDestId())
        lastID = destinationID_list[-1]
        newId = int(lastID) + 1
        newId = '0' + str(newId)
        return newId
Ejemplo n.º 2
0
 def __init__(self):
     self.mainObject = MainIO()
Ejemplo n.º 3
0
class StaffLL:
    def __init__(self):
        self.mainObject = MainIO()

    '''Returns MainIO function call'''

    def getAllStaff(self):
        return self.mainObject.getStaffIO()

    '''Takes in ssn, gets list of all staff objects. Iterates through list,
       compares ssn to staffMember ssn, returns desired staffmember object'''

    def getStaffByID(self, ssn):
        staffObject_list = self.mainObject.getStaffIO()
        for staffMember in staffObject_list:
            if staffMember.getSSN() == ssn:
                return staffMember

    '''Gets list of all staff objects, finds all staff with role pilot and returns pilot object list'''

    def getAllPilots(self):
        staffObject_list = self.mainObject.getStaffIO()
        pilotObject_list = []
        for staffMember in staffObject_list:
            if staffMember.getRole() == 'pilot':
                pilotObject_list.append(staffMember)
        return pilotObject_list

    '''Gets list of all staff objects, finds all staff with role cabincrew and returns cabincrew object list'''

    def getAllCabinCrew(self):
        staffObject_list = self.mainObject.getStaffIO()
        pilotObject_list = []
        for staffMember in staffObject_list:
            if staffMember.getRole() == 'cabincrew':
                pilotObject_list.append(staffMember)
        return pilotObject_list

    '''Takes in ssn, gets list of all staff objects. Iterates through list,
       compares ssn to staffMember ssn, returns desired staffmember object'''

    def getStaffData(self, dataList):
        staffObject_list = self.mainObject.getStaffIO()
        for staffMember in staffObject_list:
            if staffMember.getSSN() == dataList[0]:
                return staffMember

    '''Recieves staff object, returns addNewStaffIO with object as parameter'''

    def addNewStaff(self, newEmployee):
        return self.mainObject.addNewStaffIO(newEmployee)

    '''Recieves workDay, finds all voyages happening on workday. Returns dictionary with voyage
       object as key and all staff objects on voyage as values'''

    def getWorkSchedule(self, workDay):
        workSchedule_list = []
        staffData = []
        voyageThisdayDict = {}
        voyage_list = self.mainObject.getVoyagesIO()

        # Iterates through all voyages, finds voyage happening on given date
        for voyage in voyage_list:
            voyageDate = voyage.getDepartureTime().split("T")
            if workDay == voyageDate[0]:
                workSchedule_list.append(voyage)

        # iterates through all voyages happening on given date, puts all staff on voyage in list
        for voyage in workSchedule_list:
            if voyage.getCaptain() != "":
                staffData.append(self.getStaffByID(voyage.getCaptain()))
                staffData.append(self.getStaffByID(voyage.getCoPilot()))
                staffData.append(self.getStaffByID(voyage.getFa1()))
                staffData.append(self.getStaffByID(voyage.getFa2()))
            else:
                staffData = voyage.getStaff()

            # sets voyage object as key and all staff list as value
            if voyage not in voyageThisdayDict:
                voyageThisdayDict[voyage] = staffData
                staffData = []
            else:
                staffData = []
        return voyageThisdayDict

    '''Recieves workday, iterates through voyages happening on given day, finds all staff that are
       not working in given voyages and puts in list'''

    def getWorkSchedlueAvailable(self, workDay):
        availableStaff = []
        unavailableStaff = []
        voyageThisdayDict = self.getWorkSchedule(workDay)
        staffObject_list = self.getAllStaff()

        # Iterates through voyages happening on given date
        for voyage in voyageThisdayDict:

            # Iterates through staffmembers working on given voyage and appends to unavailablestaff
            for workingStaff in voyageThisdayDict[voyage]:
                unavailableStaff.append(workingStaff)

        # iterates through all staff, if staff object is not in unavailable staff, staffmember is available
        for staffMember in staffObject_list:
            if staffMember.getSSN() not in unavailableStaff:
                availableStaff.append(staffMember)

        return availableStaff
Ejemplo n.º 4
0
class AirplaneLL:
    '''Instance of MainIO created in constructor to give the class access to 
       all IO layer functionality'''
    def __init__(self):
        self.mainObject = MainIO()

    '''Recieves newAirplane object, passes it down into MainIO'''

    def addAirplane(self, newAirplane):
        return self.mainObject.addNewAirplaneIO(newAirplane)

    '''Returns MainIO function call that returns list of all airplanes as objects'''

    def getAirplanes(self):
        return self.mainObject.getAirplanesIO()

    '''Checks status of all airplanes at a given date and time, returns dictionary with airplaneID as key and status
       as value.'''

    def getAirplaneStatus(self, date, time):
        airplaneStatus_dict = {}
        voyagePair_list = []
        temp_list = []

        # Lists of all airplane objects and voyage objects created
        airplaneObject_list = self.mainObject.getAirplanesIO()
        voyageObject_list = self.mainObject.getVoyagesIO()

        # Input date and time split into lists, datetime object created out of lists
        date_list = date.split('-')
        time_list = time.split(':')
        dateObject = datetime.datetime(int(date_list[0]), int(date_list[1]),
                                       int(date_list[2]), int(time_list[0]),
                                       int(time_list[1]))

        # voyages pairs put into lists, pairs then put into voyagePair_list
        counter = 1
        for voyage in voyageObject_list:
            temp_list.append(voyage)
            if counter % 2 == 0:
                voyagePair_list.append(temp_list)
                temp_list = []
            counter += 1

        for voyage in voyagePair_list:

            # datetime objects created out of voyage pair departure and arrival times
            voyageOneDeparting = dateutil.parser.parse(
                voyage[0].getDepartureTime())
            voyageOneArriving = dateutil.parser.parse(
                voyage[0].getArrivalTime())
            dateOneDeparting = datetime.datetime(voyageOneDeparting.year,
                                                 voyageOneDeparting.month,
                                                 voyageOneDeparting.day,
                                                 voyageOneDeparting.hour,
                                                 voyageOneDeparting.minute)
            dateOneArriving = datetime.datetime(voyageOneArriving.year,
                                                voyageOneArriving.month,
                                                voyageOneArriving.day,
                                                voyageOneArriving.hour,
                                                voyageOneArriving.minute)

            voyageTwoDeparting = dateutil.parser.parse(
                voyage[1].getDepartureTime())
            voyageTwoArriving = dateutil.parser.parse(
                voyage[1].getArrivalTime())
            dateTwoDeparting = datetime.datetime(voyageTwoDeparting.year,
                                                 voyageTwoDeparting.month,
                                                 voyageTwoDeparting.day,
                                                 voyageTwoDeparting.hour,
                                                 voyageTwoDeparting.minute)
            dateTwoArriving = datetime.datetime(voyageTwoArriving.year,
                                                voyageTwoArriving.month,
                                                voyageTwoArriving.day,
                                                voyageTwoArriving.hour,
                                                voyageTwoArriving.minute)

            # If statement cluster to determine status of each airplane at a given time. Results put into dictionary with airplaneID as key and status as value
            if dateObject.date() != dateOneDeparting.date():
                if dateObject.date() != dateTwoDeparting.date():
                    airplaneStatus_dict[
                        voyage[0].getAircraftId()] = 'Available'
            else:
                if dateOneDeparting > dateObject:
                    airplaneStatus_dict[voyage[0].getAircraftId(
                    )] = 'Voyage today to ' + voyage[0].getArrivingAt()
                elif dateTwoArriving < dateObject:
                    airplaneStatus_dict[
                        voyage[0].getAircraftId()] = 'Available'
                else:
                    if dateOneDeparting < dateObject:
                        if dateOneArriving > dateObject:
                            airplaneStatus_dict[voyage[0].getAircraftId(
                            )] = 'In transit from ' + voyage[
                                0].getDepartingFrom(
                                ) + ' to ' + voyage[0].getArrivingAt()
                        elif dateTwoDeparting < dateObject:
                            if dateTwoArriving > dateObject:
                                airplaneStatus_dict[voyage[1].getAircraftId(
                                )] = 'In transit from ' + voyage[
                                    1].getDepartingFrom(
                                    ) + ' to ' + voyage[1].getArrivingAt()
                            else:
                                airplaneStatus_dict[voyage[1].getAircraftId(
                                )] = 'In voyage to ' + voyage[1].getArrivingAt(
                                )
                        else:
                            airplaneStatus_dict[voyage[0].getAircraftId(
                            )] = 'In voyage to ' + voyage[0].getArrivingAt()

        # If an airplane is not in airplaneStatus_dict it means that the airplane has no voyage on given date, then available
        for airplane in airplaneObject_list:
            if airplane.getPlaneId() not in airplaneStatus_dict:
                airplaneStatus_dict[airplane.getPlaneId()] = 'Available'

        return airplaneStatus_dict

    '''Recieves ID, creates dict of all airplanes and licensed pilots. Iterates through dict,
       finds appropriate license and returns dict containing only desired airplane id and 
       licensed pilots'''

    def getAirplaneByID(self, ID):
        license_dict = self.getLicenseDict()
        return_dict = {}
        for pilotLicense in license_dict:
            if pilotLicense == ID:
                return_dict[pilotLicense] = license_dict[pilotLicense]
        return return_dict

    '''Recieves dataList and returns addLicenseIO function call'''

    def addLicense(self, dataList):
        return self.mainObject.addLicenseIO(dataList)

    '''Gets list of all staff as objects from getStaffIO function call. Iterates through list
       and finds all staff that have pilot as role. Returns list of only pilot objects'''

    def getAllPilots(self):
        staffObject_list = self.mainObject.getStaffIO()
        pilotObject_list = []
        for staffMember in staffObject_list:
            if staffMember.getRole() == 'pilot':
                pilotObject_list.append(staffMember)
        return pilotObject_list

    '''Returns dictionary with all airplane IDs as keys and all licensed pilots on each 
       airplane as values'''

    def getLicenseDict(self):
        # Get lists of all staff objects and airplane objects through MainIO function calls
        staffObject_list = self.mainObject.getStaffIO()
        aiprlaneObject_list = self.mainObject.getAirplanesIO()
        pilotObject_list = []
        license_Dict = {}

        # All pilots found and put into pilotObject_list
        for staffMember in staffObject_list:
            if staffMember.getRole() == 'pilot':
                pilotObject_list.append(staffMember)

        # Iterates through pilot list, sets license as key and pilot name as value
        for staffMember in pilotObject_list:
            if staffMember.getLicense() not in license_Dict:
                license_Dict[staffMember.getLicense()] = [
                    staffMember.getName()
                ]
            # If airplane is already in dict, pilot is appended to value
            else:
                license_Dict[staffMember.getLicense()].append(
                    staffMember.getName())

        # If airplane is not in license_dict, no pilot is licensed on given airplane
        for airplane in aiprlaneObject_list:
            if airplane.getPlaneId() not in license_Dict:
                license_Dict[airplane.getPlaneId()] = ['No licensed pilot']
        return license_Dict
Ejemplo n.º 5
0
class VoyageLL():
    '''Instances of appropriate classes created in constructor so the class
       has access to their functions. MainLL connects the class to the logic layer
       and the other classes handle inputs, outputs and errors'''
    def __init__(self):
        self.mainObject = MainIO()
  
    def listVoyage(self):
        """ Returns a dictionary where the keys are voyages and their values are staff members. """
        voyageObject_list = self.mainObject.getVoyagesIO()
        staffObject_list = self.mainObject.getStaffIO()
        voyage_dict = {}
        for voyage in voyageObject_list:
            if voyage.getStaff() == ['', '', '', '']:  # If there is no staff assigned to the voyage,
                voyage_dict[voyage] = voyage.getStaff()  # Then assign the staff to the voyage.
            else:
                for staffMember in staffObject_list:
                    if staffMember.getSSN() in voyage.getStaff():
                        if voyage in voyage_dict:
                            voyage_dict[voyage].append(staffMember)
                        else:
                            voyage_dict[voyage] = [staffMember]
        return voyage_dict

    def addVoyages(self, newFlight):
        ''' Takes a voyage model and returns the addNewVoyageIO method in the MainIO. '''
        return self.mainObject.addNewVoyageIO(newFlight)

    def updateVoyage(self, dataList, staffList):
        '''Takes a voyage model and returns the updateVoyageIO method in the MainIO. '''
        return self.mainObject.updateVoyageIO(dataList, staffList)

    def generateFlightNumber(self, flight):
        ''' Generates a flight number for the flight to the destination and back. If there are no flights to the target destination
            at the target date then we simply add 2 zeros to "NA" and the destination Id then returns the correct flight number'''
        flightNumberList = []
        destination = flight.getArrivingAt()
        voyageList = self.mainObject.getVoyagesIO()
        destinationList = self.mainObject.getDestinationsIO()
        for dest in destinationList:
            if dest.getCountry() == destination:
                destId = dest.getDestId()                       # Finds the destination Id for the flight
        flightDate = flight.getDepartureTime().split("T")
        currentDate = flightDate[0].split('-')                  # index 0 should be the date
        currentDateObject = datetime.datetime(int(currentDate[0]), int(currentDate[1]), int(currentDate[2])) # Create a dateTimeobject from the flight


        for i, voyage in enumerate(voyageList): # we use enumerate because one voyage is 2 flights in 2 lines.
            bookedFlightNum = voyage.getDepartureTime().split("T")
            date_list = bookedFlightNum[0].split('-')
            dateObject = datetime.datetime(int(date_list[0]), int(date_list[1]), int(date_list[2]))
            if dateObject == currentDateObject and voyage.getArrivingAt() == flight.getArrivingAt(): # If it finds a flight to the same destination
                                                                                                     # And with the same date then generate a flight number
                flightIdFirst = voyage.getFlightNumber()                                             # for this flight and the one after (2flights=1voyage)
                flightNumberList.append(int(flightIdFirst[-2:]))
                try:
                    flightIdSecond = voyageList[i + 1].getFlightNumber()
                    flightNumberList.append(int(flightIdSecond[-2:]))
                except IndexError:
                    pass
                except Exception as e:
                    print(e)

        if flightNumberList == []:
            return "NA" + destId + "00"         # If there there are no flight that day to that destination then give it NAXX00
        else:
            findMostRecent = max(flightNumberList)
            if findMostRecent >= 10:            # If the flight number has not reached 10 then we add "0" to it
                newFlightNumber = "NA" + destId + str(findMostRecent + 1)
            else:
                newFlightNumber = "NA" + destId + "0" + str(findMostRecent + 1)
        return newFlightNumber

    def findArrivalTime(self, flight):
        '''Creates the arrival time, calculated by the flight time to the destination '''
        allDest = self.mainObject.getDestinationsIO()
        for dest in allDest:
            if dest.getCountry() == flight.getArrivingAt():
                flightTime = dest.getFlightTime()
        try:
            if flightTime == "0":           # keflavik has the flighttime of 0 so if the flight is arriving to keflavik
                for dest in allDest:        # then we calculate with the flight time of departing destination
                    if dest.getCountry() == flight.getDepartingFrom():
                        flightTime = dest.getFlightTime()
        except UnboundLocalError:
            return False
        departureTimeTemp = flight.getDepartureTime().split("T")
        departureTime = " ".join(departureTimeTemp)
        tdelta = datetime.timedelta(hours=int(flightTime))

        datetime_object = datetime.datetime.strptime(departureTime, '%Y-%m-%d %H:%M:%S')
        totalTime = datetime_object + tdelta
        updatedTime = datetime.datetime.strftime(totalTime,'%Y-%m-%dT%H:%M:%S')

        return updatedTime

    def flightCollision(self, flight):
        ''' Checks if the new flight is departing at the same time as another flight.
            We only check by the minute, a airplane can take off at 16:00 and another at 16:01'''
        voyageList = self.mainObject.getVoyagesIO()
        flightTime = flight.getDepartureTime()[:-2] # Takes the seconds of the time
        for voyage in voyageList:
            voyageTime = voyage.getDepartureTime()[:-2]
            if voyageTime == flightTime:
                return True
            else:
                pass

    def availableDates(self):
        '''Finds the dates where there are booked voyages and returns a list of those dates '''
        availableDates_list = []
        voyageObject_list = self.mainObject.getVoyagesIO()
        for voyage in voyageObject_list:
            departureTime = voyage.getDepartureTime()
            date = departureTime.split('T')
            if date[0] not in availableDates_list:
                availableDates_list.append(date[0])
        return availableDates_list

    def getWorkWeek(self, dataList):
        workWeekObject_list = []
        voyageObject_list = self.mainObject.getVoyagesIO()
        for voyage in voyageObject_list:
            departureDateTime = voyage.getDepartureTime()
            parsedDateObject = dateutil.parser.parse(departureDateTime)
            timeCompare = datetime.datetime(parsedDateObject.year, parsedDateObject.month, parsedDateObject.day)
            if timeCompare >= dataList[0]:
                if timeCompare <= dataList[1]:
                    if dataList[2] in voyage.getStaff():
                        workWeekObject_list.append(voyage)
        return workWeekObject_list

    def findAvalibleAirplanes(self, flight):
        '''Gets a list with all Nan airplanes, removes those that are unavailable today. Returns one airplane from a the list'''

        allNanPlanes = self.mainObject.getAirplanesIO()
        allVoyages = self.mainObject.getVoyagesIO()
        dateToFind = flight.getDepartureTime().split("T")
        allavalibleAirplanes = []
        for plane in allNanPlanes:
            allavalibleAirplanes.append(plane.getPlaneId()) # List of all airplanes

        for voyage in allVoyages:
            uppcomingVoyageDates = voyage.getDepartureTime().split("T")
            if uppcomingVoyageDates[0] == dateToFind[0]:
                busyAirplanes = voyage.getAircraftId()
                try:                                            # we use try because for each voyage we only want to remove the airplane once
                    allavalibleAirplanes.remove(busyAirplanes)  # where the airplane appears 2 times we pass when we remove it again
                except ValueError:
                    pass
        if allavalibleAirplanes == []:                          # the list is empty if there are no available airplanes
            return False
        else:
            return random.choice(allavalibleAirplanes)          # Returns the a random airplane

    def getAllCaptains(self):
        """ Gets all staff members and returns a list of all captains. """
        staffObject_list = self.mainObject.getStaffIO()
        captainObject_list = []
        for staffMember in staffObject_list:
            if staffMember.getRank() == 'captain':
                captainObject_list.append(staffMember)
        return captainObject_list

    def getAllCoPilots(self):
        """ Gets all staff members and returns a list of all Co-pilots. """
        staffObject_list = self.mainObject.getStaffIO()
        coPilotObject_list = []
        for staffMember in staffObject_list:
            if staffMember.getRank() == 'copilot':
                coPilotObject_list.append(staffMember)
        return coPilotObject_list

    def getAllFlightAttendants(self):
        """ Gets all staff members and returns a list of all flight attendants. """
        staffObject_list = self.mainObject.getStaffIO()
        flightAttendantObject_list = []
        for staffMember in staffObject_list:
            if staffMember.getRank() == 'flight attendant':
                flightAttendantObject_list.append(staffMember)
        return flightAttendantObject_list

    def getAllFlightServiceManagers(self):
        """ Gets all staff members and returns a list of all flight service managers. """
        staffObject_list = self.mainObject.getStaffIO()
        flightServiceManagerObject_list = []
        for staffMember in staffObject_list:
            if staffMember.getRank() == 'flight service manager':
                flightServiceManagerObject_list.append(staffMember)
        return flightServiceManagerObject_list

    def findAvailableFlightAttendants(self, flight):
        """ This method takes a flight as an argument, gets all flight attendants, all voyages and the desired date.
        Returns all available flight attendants for that date. """
        allFlightAttendants = self.getAllFlightAttendants()
        allVoyages = self.mainObject.getVoyagesIO()
        dateToFind = flight.getDepartureTime().split("T")
        allAvalibleFlightAttendants = []
        for flightAttendant in allFlightAttendants:
            allAvalibleFlightAttendants.append(flightAttendant.getName())  # Appending all flight attendants to the list of all available flight attendants.

        busyflightAttendants = []
        for voyage in allVoyages:
            uppcomingVoyageDates = voyage.getDepartureTime().split("T")
            if uppcomingVoyageDates[0] == dateToFind[0]:  # Index 0 of upcoming voyage date is the date.
                if voyage.getFa2() not in busyflightAttendants:
                    busyflightAttendants.append(voyage.getFa2())
                    try:
                        for flightAttendant in busyflightAttendants:  # Filtering out busy flight attendants from the list of all available flight attendants.
                            if flightAttendant in allAvalibleFlightAttendants:
                                allAvalibleFlightAttendants.remove(flightAttendant)
                            else:
                                pass
                    except ValueError:
                        pass
        if allAvalibleFlightAttendants == []:
            return False
        else:
            return allAvalibleFlightAttendants

    def findAvailableFlightServiceManagers(self, flight):
        """ This method takes a flight as an argument, gets all flight service managers, all voyages and the desired date.
        Returns all available flight service managers for that date. """
        allFlightServiceManagers = self.getAllFlightServiceManagers()
        allVoyages = self.mainObject.getVoyagesIO()
        dateToFind = flight.getDepartureTime().split("T")
        allAvalibleFlightServiceManagers = []
        for FlightServiceManager in allFlightServiceManagers:
            allAvalibleFlightServiceManagers.append(FlightServiceManager.getName())  # Appending all flight service managers to the list of all available flight service managers.

        busyFlightServiceManagers = []
        for voyage in allVoyages:
            uppcomingVoyageDates = voyage.getDepartureTime().split("T")
            if uppcomingVoyageDates[0] == dateToFind[0]:  # Index 0 of upcoming voyage date is the date.
                if voyage.getFa1() not in busyFlightServiceManagers:
                    busyFlightServiceManagers.append(voyage.getFa1())
                    try:
                        for FlightServiceManager in busyFlightServiceManagers:  # Filtering out busy flight attendants from the list of all available flight service managers.
                            if FlightServiceManager in allAvalibleFlightServiceManagers:
                                allAvalibleFlightServiceManagers.remove(FlightServiceManager)
                            else:
                                pass
                    except ValueError:
                        pass
        if allAvalibleFlightServiceManagers == []:
            return False
        else:
            return allAvalibleFlightServiceManagers

    def findAvailableCoPilots(self, flight):
        """ This method takes a flight as an argument, gets all co-pilots, all voyages and the aircraft id for the voyage.
        Returns all available co-pilots for that date that also have license on the specific aircraft. """
        allCoPilots = self.getAllCoPilots()
        allVoyages = self.mainObject.getVoyagesIO()
        dateToFind = flight.getDepartureTime().split("T")
        idToFind = flight.getAircraftId()
        allAvalibleCoPilots = []
        for coPilot in allCoPilots:
            allAvalibleCoPilots.append(coPilot.getName())  # Appending all co-pilots to the list of all available co-pilots.

        busyCoPilots = []
        for voyage in allVoyages:
            uppcomingVoyageDates = voyage.getDepartureTime().split("T")
            if uppcomingVoyageDates[0] == dateToFind[0]:  # Index 0 of upcoming voyage date is the date.
                if voyage.getCoPilot() not in busyCoPilots:
                    busyCoPilots.append(voyage.getCoPilot())
                    try:
                        for coPilot in busyCoPilots:  # Filtering out busy co-pilots from the list of all available co-pilots.
                            if coPilot in allAvalibleCoPilots:
                                allAvalibleCoPilots.remove(coPilot)
                            else:
                                pass
                    except ValueError:
                        pass
        if allAvalibleCoPilots == []:
            return False
        else:
            qualifiedCoPilots = []  # New list that will be returned which will contain only available co-pilots that also have license on the specific aircraft.
            for coPilot in allCoPilots:
                if coPilot.getLicense() == idToFind and coPilot.getName() in allAvalibleCoPilots:
                    qualifiedCoPilots.append(coPilot)
            return qualifiedCoPilots

    def findAvailableCaptains(self, flight):
        """ This method takes a flight as an argument, gets all captains, all voyages and the aircraft id for the voyage.
        Returns all available captains for that date that also have license on the specific aircraft. """
        allCaptains = self.getAllCaptains()
        allVoyages = self.mainObject.getVoyagesIO()
        dateToFind = flight.getDepartureTime().split("T")
        idToFind = flight.getAircraftId()
        allAvalibleCaptains = []
        for captain in allCaptains:
            allAvalibleCaptains.append(captain.getName())  # Appending all captains to the list of all available captains.

        busyCaptains = []
        for voyage in allVoyages:
            uppcomingVoyageDates = voyage.getDepartureTime().split("T")
            if uppcomingVoyageDates[0] == dateToFind[0]:  # Index 0 of upcoming voyage date is the date.
                if voyage.getCaptain() not in busyCaptains:
                    busyCaptains.append(voyage.getCaptain())
                    try:
                        for captain in busyCaptains:  # Filtering out busy captains from the list of all available captains.
                            if captain in allAvalibleCaptains:
                                allAvalibleCaptains.remove(captain)
                            else:
                                pass
                    except ValueError:
                        pass
                if allAvalibleCaptains == []:
                    return False
                else:
                    qualifiedCaptains = []  # New list that will be returned which will contain only available captains that also have license on the specific aircraft.
                    for captain in allCaptains:
                        if captain.getLicense() == idToFind and captain.getName() in allAvalibleCaptains:
                            qualifiedCaptains.append(captain)

                    return qualifiedCaptains

    def errorCheckDate(self, flight):
        ''' Uses a few method to error check the user date and time and returns a error message and False if it fails the checker,
         else True. we mostly use try and except and changing the string to int '''

        errorMessageDate = "Date was not entered correctly (YYYY-MM-DD), please try again "
        errorMessageTime = "Time was not entered correctly (HH:MM), please try again"
        flightTime = flight.getDepartureTime()
        date = flightTime.split("T") # date[0] is the date, date[1] is the time
        try:
            year, month, day = date[0].split("-")
            temp = datetime.date(int(year), int(month), int(day))
            if len(year) != 4:
                print(errorMessageDate)
                return False
        except ValueError:
            print(errorMessageDate)
            return False
        try:
            temp = datetime.date(int(year), int(month), int(day))
        except TypeError:
            print(errorMessageDate)
            return False
        try:
            hour, minute, second = date[1].split(":")
            temp = datetime.time(int(hour), int(minute))
        except ValueError:
            print(errorMessageTime)
            return False
        try:
            temp = datetime.time(int(hour), int(minute))
        except TypeError:
            print(errorMessageTime)
            return False
        return True

    def generateSecondFlight(self, firstFlight):
        ''' When creating a voyage the user only needs to input where he will be arriving at and when he want the flight to depart.
        Those information are sufficient to generate rest of the information as well as the returning flight'''
        departingFrom = firstFlight.getArrivingAt() # flight2 will depart from flight1 arriving destination
        arravingAt = firstFlight.getDepartingFrom() # flight 2 will always fly back to keflavik
        airplane = firstFlight.getAircraftId()      # flight 2 uses the same airplane
        departureTimeTemp = firstFlight.getArrivalTime().split("T") # use the same method that generated flight 1 arriving time
        departureTime = " ".join(departureTimeTemp)
        tdelta = datetime.timedelta(hours=int(1))   # add one hour for docking and refueling
        datetime_object = datetime.datetime.strptime(departureTime, '%Y-%m-%d %H:%M:%S')
        newDepartureTime = datetime_object + tdelta
        newtime = datetime.datetime.strftime(newDepartureTime, '%Y-%m-%dT%H:%M:%S')

        return departingFrom, arravingAt, newtime, airplane