Ejemplo n.º 1
0
 def __init__(self):
     self.desIO = DestinationIO('IO/Data/Destinations.csv') # Hardcoded filenames - Only place to change the path is here
     self.voyIO = VoyageIO('IO/Data/Voyages.csv')
     self.plaIO = PlaneIO('IO/Data/Planes.csv')
     self.empIO = EmployeeIO('IO/Data/Crew.csv')
     self.rouIO = RouteIO('IO/Data/Routes.csv')
     self.typIO = PlaneTypeIO('IO/Data/AircraftType.csv')
Ejemplo n.º 2
0
from model.AirplaneM import Airplane
from IO.airplaneIO import AirplaneIO

from model.employeeM import Employee
from IO.employeeIO import EmployeeIO

a = AirplaneIO()
a.load_airplane_from_file()
print(a)

a = EmployeeIO()
a.load_employee_from_file("status")
print(a)

inp = input()
Ejemplo n.º 3
0
 def __init__(self):
     self.__employee = EmployeeIO()
Ejemplo n.º 4
0
class EmployeeLL():
    def __init__(self):
        self.__employee = EmployeeIO()
    
    def check_for_ssn(self, check):
        employee_set = self.__employee.get_set()
        for elements in employee_set:
            if check == elements:
                return True

    def check_if_ssn_exists(self, check):
        employee_set = self.__employee.get_set()
        for elements in employee_set:
            if check == elements:
                return False
        else: 
            return True

    def check_if_user_name_exists(self,check):
        user_name_set = self.__employee.get_user_name_set()
        for elements in user_name_set:
            if check == elements:
                print("This username is already being used")
                return False
        else: 
            return True

    def display_pilots_by_licence(self,plane_insignia):
        return self.__employee.display_by_licence(plane_insignia)

    def validate_name(self,name):
        """Checks if name is valid and Returns True if it is valid"""
        name = name.split()
        for elements in name:
            for letter in elements:
                if not letter.isalpha():
                    return False
        return True

    def validate_ssn(self,ssn):
        """Checks if the ssn is valid. Returns True if it is valid"""
        
        if self.check_if_ssn_exists(ssn):
            try: 
                int(ssn)

            except ValueError:
                return False

            if len(ssn) == 10:
                return True

    def validate_phone_number(self, phone_number):
        """Checks if the phone number is valid. Returns True if it is valid"""
        try: 
            int(phone_number)
        except ValueError: 
            return False

        if len(phone_number) == 7:
            return True

    def validate_address(self,address):
        address = address.split()
        for letter in address[0]:
            if not letter.isalpha():
                return False

        return True

    def check_if_available(self,date,rank):
        self.__employee.check_if_available_and_has_licence(date,rank)
        return str(self.__employee)

    def check_if_matches(self,date,rank):
        self.__employee.check_if_available_and_has_licence(date,rank)
        return self.__employee.get_employee_list()

    def check_if_in_available(self,date,rank,ssn):
        if ssn.upper() != "N/A":
            a = self.check_if_matches(date,rank)
            for employee in a:
                if employee.get_ssn() == ssn:
                    return True
            return False
        else: 
            return True

    def validate_user_name(self, user):
        """Checks if the user name is valid. Returns True if it is valid"""
        if self.check_if_user_name_exists(user):
            if len(user) >= 4:
                return True
            else: 
                print("The user name has to be longer than or equal to 4 letters")
                return False
        else:
            return False
    
    def validate_rank(self, rank):
        """Checks if the rank is valid. Returns True if it is valid"""
        if rank.lower() == "flight attendant" or rank.lower() == "flight service manager" \
        or rank.lower() ==  "co-pilot" or rank.lower() == "captain":
            return True

    def validate_permit(self,permit):
        if permit == "N/A" or permit == "n/a" :
            return True

        for letter in permit:
            if not letter.isalpha() and not letter.isdigit():
                return False
        return True

    def add_employee(self,value_string):
        ssn,name,address,phone_number,user_name,rank,permits= value_string.split(",")
        self.__employee.Add_employee_to_file(ssn,name,address,phone_number,user_name,rank,permits)

    def change_employee(self, ssn, change, new):
        self.__employee.change_employee(ssn, change, new)

    def display_pilots(self, a):
        self.__employee.display_pilots(a)
        return str(self.__employee)
    
    def sort_employees_by_alpha(self):
        self.__employee.load_employee_from_file("alpha")
        return str(self.__employee)

    def show_by_status(self, a):
        self.__employee.display_status(a)
        return str(self.__employee)

    def show_flight_atendants(self):
        self.__employee.display_flight_attendants()
        return str(self.__employee)

    def show_single_employee(self, ssn):
        self.__employee.display_one_employee(ssn)
        return str(self.__employee)
Ejemplo n.º 5
0
class IOAPI ():

    def __init__(self):
        self.desIO = DestinationIO('IO/Data/Destinations.csv') # Hardcoded filenames - Only place to change the path is here
        self.voyIO = VoyageIO('IO/Data/Voyages.csv')
        self.plaIO = PlaneIO('IO/Data/Planes.csv')
        self.empIO = EmployeeIO('IO/Data/Crew.csv')
        self.rouIO = RouteIO('IO/Data/Routes.csv')
        self.typIO = PlaneTypeIO('IO/Data/AircraftType.csv')

    def loadDestinationFromFile (self):
        return self.desIO.loadFile()
    
    def storeDestinationToFile(self,dest):
        return self.desIO.storeDestinationToFile(dest)

    def updateContactInfoInFile(self,line_index,row_index,updated_info):
        return self.desIO.updateContactInfoInFile(line_index,row_index,updated_info)

    def loadVoyagesFromFile (self):
        return self.voyIO.loadFile()
    
    def storeVoyageToFile(self,voyage):
        routeOut = voyage.getRouteOut()
        routeIn = voyage.getRouteIn()
        self.rouIO.storeRouteOutToFile(routeOut)
        self.rouIO.storeRouteInToFile(routeIn)
        return self.voyIO.storeVoyageToFile(voyage)

    def updateVoyageInFile(self):
        return self.voyIO.updateVoyageInFile()

    def loadPlanesFromFile(self):
        return self.plaIO.loadFile()

    def storePlaneToFile(self,plane):
        return self.plaIO.storePlaneToFile(plane)

    def storePlaneTypeToFile(self,planeType):
        return self.typIO.storePlaneTypeToFile(planeType)
    
    def loadPlaneTypesFromFile(self):
        return self.typIO.loadFile()

    def loadEmployeesFromFile(self):
        return self.empIO.loadFile()

    def storeEmployeeToFile(self,employee):
        return self.empIO.storeEmployeeToFile(employee)

    def updateEmployeeInFile(self,line_index,row_index,updated_info):
        return self.empIO.updateEmployeeInFile(line_index,row_index,updated_info)

    def loadRoutesFromFile(self):
        return self.rouIO.loadFile()

    def storeRouteToFile(self):
        return self.rouIO.storeRouteToFile()

    def storeCrewToFile(self,voyage):
        return self.voyIO.storeCrewToFile(voyage)
        
    def storeRouteOutToFile(self,routeOut):
        return self.rouIO.storeRouteOutToFile(routeOut)

    def storeRouteInToFile(self,routeIn):
        return self.rouIO.storeRouteInToFile(routeIn)
Ejemplo n.º 6
0
 def __init__(self):
     self.__io_voyage = VoyageIO()
     self.__employee = EmployeeIO()
     self.__destinatio = DestinationIO()
Ejemplo n.º 7
0
 def __init__(self):
     self.__airplaneio = AirplaneIO()
     self.__employeeio = EmployeeIO()
Ejemplo n.º 8
0
class AirplaneLL(Airplane):
    def __init__(self):
        self.__airplaneio = AirplaneIO()
        self.__employeeio = EmployeeIO()

    def check_if_exists(self, check, num):
        destination_set = self.__airplaneio.get_set(num)
        for elements in destination_set:
            if check == elements:
                return True
        else:
            return False

    def validate_manufacturer(self, manufacturer):
        """ Validates whether "manufacturer" is a string and whether or not every letter is a part of the alphabet. """
        if type(manufacturer) == str:
            for letter in manufacturer:
                if not letter.isalpha():
                    return False
            return True
        return False

    def validate_typeID(self, type_ID):
        """ validates whether "type_ID" is a string and if every letter is either a numeral or a part of the alphabet """
        if type(type_ID) == str:
            for letter in type_ID:
                if not letter.isalpha() and not letter.isdigit():
                    return False
            return True
        return False

    def validate_plane_insignia(self, plane_insignia):
        """ Validates whether "plane_insignia" is a string, if it has the right format and whether or not every letter, outside of "-" is a part of the alphabet """
        if type(plane_insignia) == str:
            if plane_insignia[0:3] != "TF-" or len(plane_insignia) != 6:
                return False
            for num, letter in enumerate(plane_insignia):
                if not letter.isalpha() and (letter != "-" and num == 2):
                    return False
            return True
        return False

    def check_if_available(self, date):
        self.__airplaneio.check_if_available(date)
        return str(self.__airplaneio)

    def check_if_matches(self, date):
        self.__airplaneio.check_if_available(date)
        return self.__airplaneio.get_airplane_list()

    def check_if_in_available(self, date, plane_insignia):
        a = self.check_if_matches(date)
        for airplane in a:
            if airplane.get_plane_insignia() == plane_insignia:
                return True
        return False

    def validate_model(self, model):
        """ validates whether "model" is a string and whether or not it's letters are numerals or in the alphabet. """
        if type(model) == str:
            for letter in model:
                if not letter.isalpha() and not letter.isdigit():
                    return False
            return True
        return False

    def create_plane(self, new_plane):
        manufacturer, type_id, plane_insignia, model = new_plane.split(",")
        self.__airplaneio.Add_airplane_to_file(manufacturer, type_id,
                                               plane_insignia, model)

    def load_from_file(self):
        self.__airplaneio.load_airplane_from_file()
        return str(self.__airplaneio)

    def display_by_licence(self, type_id):
        self.__employeeio.display_by_licence(type_id)
        return str(self.__employeeio)