Exemplo n.º 1
0
def main():
    """
    Ejecuta el Programa Principal
    :return:
    """
    ## Sin Solid
    # Procesador = PetWash1(1234)

    ## Responsabilidad Unica
    # Procesador = PetWash2(1234)

    ## mas Inversión de las dependencias
    #repository = MemoryRepository()
    #notifier = SMSNotifier(1234)
    #Procesador = PetWash3(repository, notifier)

    ## mas Open Close
    repository = MemoryRepository()
    #notifier = NotifierSMSImplementation(token=12345)
    notifier = NotifierEmailImplementation(token=12345)
    Procesador = PetWash4(repository, notifier)

    # Procesador = PetWash5(1234)   # mas Liskov
    # Procesador = PetWash6(1234)   # mas -----
    continuar = True

    while continuar:

        # input
        cliente = input("Ingrese El nombre de cliente: ")
        mascota = input("Ingrese El nombre de la Mascota: ")
        mascota_type = input("Ingrese El tipo de Mascota: ")
        cliente_num = input("Ingrese El número de Contacto: ")
        cliente_email = input("Ingrese un correo electronico de Contacto: ")

        customer = Customer(name=cliente,
                            mobile_phone=cliente_num,
                            email=cliente_email)
        pet = Pet(name=mascota, type=mascota_type)
        print("Customer Info", customer.get_info())
        print("Pet Info", pet.get_info())

        #jobIdentifier = Procesador.require_pet_wash(pet, customer) # Para Solid1 and Solid 2

        job = PetWashJob(
            pet, customer,
            'new job')  # Para Inversión de dependencias, open_close
        jobIdentifier = Procesador.require_pet_wash(job)

        variable: str = 23
        print(variable, type(variable))

        Procesador.wash_completed(jobIdentifier)

        continuar = False
Exemplo n.º 2
0
    def get_customer(self):
        customer_dict = {}
        with open("./data/Customers.csv", "r") as Customer_file:
            csv_reader = csv.reader(Customer_file)
            next(csv_reader)
            
            for line in csv_reader:
                email, name, phone, creditcard = line
                new_customer = Customer(email, name, phone, creditcard)
                key = new_customer.get_email() #key er email
              
                customer_dict[key] = new_customer

        return customer_dict
 def registerNewCustomer(self, name, ssn, address, phone_number,
                         driverslicense_number):
     new_customer = Customer(name, ssn, address, phone_number,
                             driverslicense_number)
     self.__customers.append(new_customer)
     self.save()
     return new_customer
Exemplo n.º 4
0
    def get_customers(self):
        self.customer_dict = {}
        with open("./data/Customers.csv", "r") as Customer_file:
            csv_reader = csv.reader(Customer_file)
            next(csv_reader)

            for line in csv_reader:
                first_name, last_name, date_of_birth, email, country, address, zip_code, phone, card, security_code, exp_date = line
                new_customer = Customer(first_name, last_name, date_of_birth,
                                        email, country, address, zip_code,
                                        phone, card, security_code, exp_date)

                key = new_customer.get_email()  #key er email
                self.customer_dict[key] = new_customer

        return self.customer_dict
Exemplo n.º 5
0
 def add_customer(self):
     name = input("Customer name: ")
     ssn = input("Customer snn: ")
     phone = input("Phone: ")
     email = input("Email: ")
     address = input("Address: ")
     cardInfo = input("Card info: ")
     return Customer(name, ssn, phone, email, address, cardInfo)
 def loadCustomers(self):
     for line in self.__customer_data:
         name = line[NAME]
         ssn = int(line[SSN])
         address = line[ADDRESS]
         phone_number = int(line[PHONENUMBER])
         driverslicense_number = int(line[DRIVERSLICENSENUMBER])
         customer = Customer(name, ssn, address, phone_number,
                             driverslicense_number)
         self.__customers.append(customer)
 def get_customer(self):
     if self.__customers == []:
         with open("./data/customers.csv", "r") as customer_file:
             for line in customer_file.readlines():
                 (name, soc_sec_num, home_address, local_address, phone_num, email, driv_license, 
                     card_num) = line.split(",")
                 new_customer = Customer(name, soc_sec_num, home_address, local_address, phone_num, email, 
                     driv_license, card_num)
                 self.__customers.append(new_customer)    
     return self.__customers
Exemplo n.º 8
0
def customer():
    """Returns customer with random data in it from Dummy()"""
    return Customer(
        D.make_name(),
        D.make_ssn(),
        D.make_address(),
        D.make_postal_code(),
        D.make_phone(),
        D.make_email(),
        D.make_country(),
        D.make_licence(),
    )
    def customer_info(self):
        additional_driver = []

        clear()
        existing = input("Existing customer(Y/N): ").upper()
        if existing == "Y":
            pass
        else:
            print("Fill in the following (*required):")
            first_name = input("\t*First Name: ")
            last_name = input("\t*Last Name: ")
            name = "{} {}".format(first_name, last_name)
            ssn = input("\t*Social Security Number: ")
            home_address = input("\t*Home Address: ")
            local_address = input("\t*Local Address: ")
            mobile_phone = input("\t*Mobile Phone: ")
            email = input("\t*Email: ")
            drivers_license = input("\t*Drivers License: ")
            card_num = input(
                "\t*Credit Card Number: "
            )  #Búið að breyta í required þarf kannski að laga ehv...
            home_phone = input(
                "\tHome Phone: ")  #Vantar þetta í customer klasann
            local_phone = input(
                "\tLocal Phone: ")  #Vantar þetta í customer klasann
            company_name = input(
                "\tCompany Name: ")  #Vantar þetta í customer klasann
            customer = Customer(name, ssn, home_address, local_address,
                                mobile_phone, email, drivers_license, card_num)
            self.__customer_repo.add_customer(customer)

            print("Additional Driver")
            add_first_name = input("\tFirst Name: ")
            additional_driver.append(add_first_name)
            add_last_name = input("\tLast Name: ")
            additional_driver.append(add_last_name)
            add_ssn = input("\tSocial Security Number: ")
            additional_driver.append(add_ssn)
            add_drivers_license = input("\tDrivers License: ")
            additional_driver.append(add_drivers_license)
            clear()
            return customer, additional_driver
Exemplo n.º 10
0
    def __init__(self, lapi, ui):
        self.logicAPI = lapi
        self.ui = ui
        self.verify = Input_Verifiers(lapi)

        # Get the number of required parameters to the init method of the class
        self.contract = [
            Contract(
                *[None for i in range(len(signature(Contract).parameters))]),
            lapi.contract
        ]
        self.customer = [
            Customer(
                *[None for i in range(len(signature(Customer).parameters))]),
            lapi.customer
        ]
        self.destination = [
            Destination(
                *[None
                  for i in range(len(signature(Destination).parameters))]),
            lapi.destination
        ]
        self.employee = [
            Employee(
                *[None for i in range(len(signature(Employee).parameters))]),
            lapi.employee
        ]
        self.vehicle = [
            Vehicle(*[None
                      for i in range(len(signature(Vehicle).parameters))]),
            lapi.vehicle
        ]
        self.vehicle_type = [
            Vehicle_Type(
                *
                [None
                 for i in range(len(signature(Vehicle_Type).parameters))]),
            lapi.vehicle_type
        ]
        self.display = Display()
Exemplo n.º 11
0
 def add_new_customer(self):
     """fall sem tekur inn upplýsingar frá notanda um nýjann viðskiptavin
     og sem síðan sendir upplýsingarnar áfram til að verða skráðar í textaskrána customer.txt"""
     #Input frá notenda um kúnnan
     first_name = input("\n\tFornafn(og millinafn): ").strip()
     last_name = input("\tEftirnafn: ").strip()
     passport = input("\tVegabréfsnúmer: ").upper().strip()
     kredit = input("\tKreditkortanúmer(engin bandstrik): ").strip()
     #upplýsingar sendar í models klasann customer
     new_customer = Customer(first_name, last_name, passport, kredit)
     #kallað í add_customer fallið í customerservice
     customer = self.__customer.add_customer(new_customer)
     #hér er kannað hvað fallið skilar, og þá er farið yfir hvort allt var rétt innslegið
     if customer == 1:
         print("\n\tEkki rétt Vegabréfsnúmer! \n\treyndu aftur\n")
         self.print_clients_menu()
         return
     elif customer == 2:
         print("\n\tEkki rétt kreditkortanúmer! \n\treyndu aftur\n")
         self.print_clients_menu()
         return
     elif customer == 3:
         print("\n\tViðskiptavinur hefur verið skráður!\n")
         self.main_menu()
Exemplo n.º 12
0
    def customer_info(self, in_database):
        ssn_valid = True
        while True:
            clear()
            while True:
                print("Customer information:")
                ssn = input("\tEnter Social Security Number: ")
                trulse = True
                # ssn = int(ssn)
                for num in ssn:
                    try:
                        int(num)
                    except:
                        trulse = False

                if (len(ssn) == 10) and (trulse == True):
                    break
                else:
                    if in_database == False:
                        _ = input(
                            "Please enter a valid Social Security Number\nPress Enter to continue..."
                        )
                    else:
                        ssn_valid = False
                        break
                clear()
                if ssn_valid == False:
                    break
            temp_customer = self.__customer_repo.search_by_ssn(
                ssn, in_database)
            if temp_customer != None:
                clear()
                confirm = self.confirm_customer(temp_customer)
                clear()
                if confirm:
                    customer = temp_customer
                    break
            else:
                clear()
                if in_database == False:
                    try_again = input(
                        "Try another Social Security Number(Y/N)?").upper()
                if in_database == True:
                    try_again = "N"
                if try_again != "Y":
                    while True:
                        clear()
                        print("Creating Customer - SSN: {}".format(ssn))
                        print("Please fill in the following information:")
                        first_name = input("\tFirst Name: ")
                        last_name = input("\tLast Name: ")
                        name = "{} {}".format(first_name, last_name)
                        home_address = input("\tHome Address: ")
                        local_address = input("\tLocal Address: ")
                        mobile_phone = input("\tMobile Phone: ")
                        email = input("\tEmail: ")
                        drivers_license = input("\tDriver's License: ")
                        card_num = input("\tCredit Card Number: ")

                        if "" in [
                                name, ssn, home_address, local_address,
                                mobile_phone, email, drivers_license, card_num
                        ]:
                            _ = input(
                                "Every criteria must be filled in.\nPress Enter to continue..."
                            )
                            clear()
                        else:
                            customer = Customer(name, ssn, home_address,
                                                local_address, mobile_phone,
                                                email, drivers_license,
                                                card_num)
                            self.__customer_repo.add_customer(customer)
                            break
                else:
                    if in_database == True:
                        break
        if in_database == False:
            additional_driver = self.get_additional_driver()
            return customer, additional_driver
        else:
            if in_database == False:
                return customer
Exemplo n.º 13
0
    def Rent_page(self):
        """ User's process when renting a car, put together in a while 
        loop, set up page by page for easy navigation """
        Page = 1  # If user inputs correctly he will go on next page
        self.section_valid = 0  # Used for Page 8 to navigate between personal information 1 and 2

        # While loop used so the user can navigate back and forth in the system
        while 0 < Page < 13:  # Stops running when user has completed the rental process
            # Variables
            if Page == 1:
                # Open location menu - Returns location - Checks if correct input
                self.location = self.__rent_menu.Page_1()
                Valid, Page = self.__Rent_valid.Check_location(
                    self.location, Page)
                if Valid:
                    Page += 1  # Moves to next page
                elif Page == 0:
                    pass
                else:
                    self.error.Wrong_location()  # Prints error message

            elif Page == 2:
                # Open date option menu - Returns pick up- and drop off dates - Checks if correct input
                self.__date_str_list = self.__rent_menu.Page_2()
                Valid, Page = self.__Rent_valid.Check_date(
                    self.__date_str_list, Page)
                if Valid:
                    Page += 1  # Moves to next page
                elif Page == 1:
                    pass  # Moves to previous page
                elif Page != 13:
                    self.error.Wrong_date()  # Prints error message

            elif Page == 3:
                # Change the input from the user to date format, input was a string.
                self.date_list = self.__Rent_service.change_str_to_date(
                    self.__date_str_list)

                # Open size option menu - Returns size of car - Checks if correct input
                self.vehicle_size = self.__rent_menu.Page_3()
                Valid, Page = self.__Rent_valid.Check_vehicle_size(
                    self.vehicle_size, Page)
                if Valid:
                    Page += 1  # Moves to next page
                elif Page == 2:
                    pass  # Moves to previous page
                elif Page != 13:
                    self.error.Wrong_vehicle_size()  # Prints error message

            elif Page == 4:
                # Finds available cars using information from the user
                available_car_list = self.__Rent_service.find_available_cars(self.date_list, \
                self.vehicle_size, self.location)
                # Returns available cars as a string.
                available_car_string = self.__Rent_service.make_carlist_string(
                    available_car_list)
                # Gets right name of size category, i.e. 1 = small cars, 2 = medium cars, 3 = SUV
                self.size_string = self.__Rent_service.get_car_size_string(
                    self.vehicle_size)

                # Opens available cars menu - Returns chosen car - Checks if correct input
                self.car_choice = self.__rent_menu.Page_4(
                    available_car_string, self.size_string)
                Valid, Page = self.__Rent_valid.Check_car_choice(
                    self.car_choice, available_car_list, Page)
                if Valid:
                    Page += 1  # Moves to next page
                elif Page == 3:
                    pass  # Moves to previous page
                elif Page != 13:
                    self.error.Wrong_car_choice()  # Prints error message

            elif Page == 5:
                # Feature_list resetted from page 6 - happens if user goes back one page
                self.feature_list, self.feature_string = self.__Rent_service.reset_features(
                )
                # Use the self.car_choice to find the desired car in the car list and returns a car_obj
                car_obj = self.__Rent_service.get_desired_car(self.car_choice)
                # Returns car from the user's inputs
                self.car_info = self.__Rent_service.desired_car_info()

                # Opens up confirmation menu - Returns confirmation - Checks if correct input
                choice = self.__rent_menu.Page_5(self.car_info)
                Valid, Page = self.__Rent_valid.Check_confirmation(
                    choice, Page)
                if Valid:
                    Page += 1  # Moves to next page
                elif Page == 4:
                    pass  # Moves to previous page
                elif Page != 13:
                    self.error.Wrong_key_pressed()  # Prints error message

            elif Page == 6:
                # Date info string, takes the self.date_list and turns it into a string.
                self.date_info = self.__Rent_service.make_date_str(
                    self.date_list)
                # Opens up additional features page - Returns chosen car - Checks if correct input
                while 5 < Page < 7:
                    choice = self.__rent_menu.Page_6()
                    Valid, Page = self.__Rent_valid.Check_feature(choice, Page)
                    if Valid and choice != "n":
                        self.feature_list = self.__Rent_service.add_features(
                            choice)
                        # Makes string of the features added
                        self.feature_string = self.__Rent_service.make_feature_string(
                            choice)
                    elif Valid and choice == "n":
                        Page += 1  # Moves to next page
                        break
                    elif not Valid and choice not in ("x", "p",
                                                      "m") and Page != 13:
                        self.error.Wrong_feature_choice(
                        )  # Prints error message

            elif Page == 7:
                # Returns final price
                additional_price, base_price = self.__Rent_service.get_price(
                    self.feature_list, car_obj)
                price_calculation = Formulas()
                price = price_calculation.calculate_price(
                    base_price, self.date_list, additional_price)
                choice = self.__rent_menu.Page_7(self.car_info, price,
                                                 self.date_info,
                                                 self.feature_string)
                Valid, Page = self.__Rent_valid.Check_confirmation(
                    choice, Page)
                if Valid:
                    Page += 1  # Moves to next page
                elif Page == 6:
                    pass  # Moves to previous page
                elif Page != 13:
                    self.error.Wrong_key_pressed()  # Prints error message

            elif Page == 8:
                # Opens up personal information menus, split to 2 sections - Returns personal info - Checks if correct input
                if self.section_valid == 0:
                    personal_info_list_1 = first_name, last_name, date_of_birth, email, choice = self.__rent_menu.Page_8_1(
                    )
                    Valid, Page = self.__Rent_valid.Check_personal_info_1(
                        personal_info_list_1, Page)
                elif self.section_valid == 1:
                    personal_info_list_2 = country, address, zip_code, phone, choice = self.__rent_menu.Page_8_2(
                    )
                    Valid, Page = self.__Rent_valid.Check_personal_info_2(
                        personal_info_list_2, Page)

                if Valid:
                    if self.section_valid == 1:
                        Page += 1  # Moves to next page
                    self.section_valid = 1
                elif Page == 7:
                    if self.section_valid == 1:  # If not true, moves to previous page
                        Page += 1
                        self.section_valid = 0
                elif Page != 13:
                    if self.section_valid == 0:
                        self.error.Wrong_personal_info_1()
                    elif self.section_valid == 1:
                        self.error.Wrong_personal_info_2()

            elif Page == 9:
                # Opens up payment method menu - Returns payment method - Checks if correct input
                self.payment_choice = self.__rent_menu.Page_9()
                Valid, Page = self.__Rent_valid.Check_payment(
                    self.payment_choice, Page)
                if Valid:
                    Page += 1  # Moves to next page
                elif Page == 8:
                    pass  # Moves to previous page
                elif Page != 13:
                    self.error.Wrong_payment_method()  # Prints error message

            elif Page == 10:
                # Opens up card information menu - Returns card info method - Checks if correct input
                if self.payment_choice in (
                        "1", "2"):  # Opens credit/debit card payment menu
                    card, security_code, exp_date, choice = self.__rent_menu.Page_10_1(
                    )
                elif self.payment_choice == "3":  # Opens up credit card insurance menu
                    card, security_code, exp_date, choice = self.__rent_menu.Page_10_2(
                    )
                card_info_list = [card, security_code, exp_date,
                                  choice]  # List of card info
                Valid, Page = self.__Rent_valid.Check_card_info(
                    card_info_list, Page)
                if Valid:
                    Page += 1  # Moves to next page
                elif Page == 9:
                    pass  # Moves to previous page
                elif Page != 13:
                    self.error.Wrong_card_info()  # Prints error message

            elif Page == 11:
                # Makes instance of Customer
                new_customer = Customer(first_name, last_name, date_of_birth,
                                        email, country, address, zip_code,
                                        phone, card, security_code, exp_date)

                # Opens up order confirmation menu - Returns choice - Checks if correct input
                choice = self.__rent_menu.Page_11(new_customer, self.car_info,
                                                  self.date_info,
                                                  self.feature_string)
                Valid, Page = self.__Rent_valid.Check_confirmation(
                    choice, Page)
                if Valid:
                    Page += 1  # Moves to next page
                elif Page == 10:
                    pass  # Moves to previous page
                elif Page != 13:
                    self.error.Wrong_key_pressed()  # Prints error message

            elif Page == 12:
                # Booking number and thank you page
                # Sends information to repos (LOG, customer, order)
                booking_num = self.__Rent_service.make_booking_num()
                self.__Rent_service.add_order_to_dict(
                    booking_num, email, car_obj.get_plate_number(),
                    self.date_list)
                self.__Rent_service.update_customer_repo(new_customer)
                self.__Rent_service.update_log(first_name, last_name, car_obj,
                                               self.date_list)
                self.__rent_menu.Page_12(booking_num)
                Page += 1
Exemplo n.º 14
0
 def edit(self, form, id):
     """Passes an edited customer directly to the data API"""
     new_customer = Customer(**form)
     self.dataAPI.edit_customer(new_customer, id)
Exemplo n.º 15
0
 def register(self, form):
     """Passes a registered customer directly to the data API"""
     new_customer = Customer(*form)
     self.dataAPI.append_customer(new_customer)