Exemplo n.º 1
0
 def __init__(self):
     # UI's
     self.__rent_menu = Print_rent_menu()
     self.error = Print_error()
     # Services
     self.__Rent_service = Rent_service()
     # Validations
     self.__Rent_valid = Rent_validation()
Exemplo n.º 2
0
 def __init__(self):
     # UI's
     self.__salesman_menu = Print_salesman_menu() 
     self.error = Print_error()
     # Controllers
     self.__rent_controller = Rent_controller()
     self.__order_controller = Order_controller()
     # Services
     self.__salesman_service = Salesman_service()
     # Variables
     self.confirmation_str = ""
     # Validations
     self.__Salesman_valid = Salesman_validation()
Exemplo n.º 3
0
 def __init__(self):
     #Services
     self.__Rent_service = Rent_service()
     #UI
     self.__rent_menu = Print_rent_menu()
     self.error = Print_error()
     #Utilizations
     self.__Rent_valid = Rent_validation()
     self.get_format = Format_text()
     # Variables
     self.menu = ""
     self.page = ""
     self.choices = ""
     self.underline = ""
Exemplo n.º 4
0
 def __init__(self):
     #Controllers
     self.__rent_controller = Rent_controller()
     self.__order_controller = Order_controller()
     #Services
     self.__salesman_service = Salesman_service()
     #UI
     self.__salesman_menu = Print_salesman_menu() 
     self.error = Print_error()
     #Utilizations
     self.__Salesman_valid = Salesman_validation()
     self.__get_format = Format_text()
     #Variables
     self.confirmation_str = ""
     self.menu = ""
     self.underline = ""
Exemplo n.º 5
0
 def __init__(self):
     # UI's
     self.__rent_menu = Print_rent_menu()
     self.error = Print_error()
     # Repo's
     self.car_class = Cars_repo()
     # Validations
     self.__Rent_valid = Rent_validation()
Exemplo n.º 6
0
 def __init__(self):
     # Repos
     self.car_repo = Cars_repo()
     self.order_repo = Orders_repo()
     self.customer_repo = Customer_repo()
     # UI's
     self.error = Print_error()
     #Utilizations
     self.__Rent_valid = Rent_validation()
     self.log_repo = Log_repo()
     #List
     self.feature_list = []
Exemplo n.º 7
0
class Salesman_controller(object):
    def __init__(self):
        # UI's
        self.__salesman_menu = Print_salesman_menu() 
        self.error = Print_error()
        # Controllers
        self.__rent_controller = Rent_controller()
        self.__order_controller = Order_controller()
        # Services
        self.__salesman_service = Salesman_service()
        # Variables
        self.confirmation_str = ""
        # Validations
        self.__Salesman_valid = Salesman_validation()
        
        

    def sign_in_page(self):
        """Gets employee's ID and password and checks if it's valid"""
        valid = False
        while valid == False:
            # Get ID
            self.__ID = self.__salesman_menu.ID_menu()
            # Get password
            self.__password = self.__salesman_menu.password_menu(self.__ID)
            # Check whether it's valid or not
            valid = self.__salesman_service.salesman_ID_pw(self.__ID,self.__password)
            if valid == False:
                try_again = input("\nID or password is invalid. Try again? (y/n): ").lower()
                if try_again != "y":
                    break

    def salesman_menu(self): 
        Page = 1
        while 0 < Page < 4:           
            if Page == 1:
                # Prints Salesman menu
                choice = self.__salesman_menu.salesman_main_page()
                Valid, Page = self.__Salesman_valid.Check_menu_choice(choice, Page)
                if Valid:
                    Page += 1 # Moves to next page
                elif Page == 0:
                    pass    # Moves to previous page
                elif Page != 4:
                    self.error.Wrong_salesmanmenu_choice() # Prints error message

            elif Page == 2:
                # Get rent process
                if choice == "1":
                    self.__rent_controller.Rent_page()

                # Search for order
                elif choice == "2":
                    Page = self.__order_controller.cancel_order_process(Page)

                # Get customer information
                elif choice == "3":
                    self.email = self.__salesman_menu.customer_info_menu()
                    Page = self.__Salesman_valid.Check_email_choice(self.email, Page)
                    if Page == 2:
                        customer = self.__salesman_service.get_customer(self.email)
                        if customer == None:
                            self.error.Wrong_email()
                        else:
                            orders = self.__salesman_service.order_string()
                            delete = self.__salesman_menu.customer_list(customer, orders)
                            if delete == "d":
                                self.__salesman_service.delete_customer(customer)
                                self.confirmation_str = "Customer"
                                action = "removed"
                                self.__salesman_service.delete_customer_to_log(self.__ID)
                                self.__salesman_menu.confirmation(self.confirmation_str, action)
                        
                # Get cars information
                elif choice == "4":
                    self.__choice = self.__salesman_menu.cars_info_menu()
                    Valid, Page = self.__Salesman_valid.Check_cars_information_choice(self.__choice, Page)
                    if Valid:
                        pass    # Moves forward
                    elif Page == 1:
                        pass    # Moves to previous page
                    elif Page != 8:
                        self.error.Wrong_car_info_choice() # Prints error message

                    if Page == 2:
                        if self.__choice == "1":
                            self.cars = self.__salesman_service.get_all_cars()

                        elif self.__choice == "2":
                            self.cars = self.__salesman_service.get_available_cars()

                        elif self.__choice == "3":
                            self.cars = self.__salesman_service.get_unavailable_cars()

                        elif self.__choice == "4":
                            plate_num, brand, size, location = self.__salesman_menu.add_car()
                            self.__salesman_service.add_car_repo(plate_num, brand, size, location)
                            self.confirmation_str = "Car"
                            action = "added"
                            self.__salesman_menu.confirmation(self.confirmation_str, action)
                            # Add to log
                            self.__salesman_service.add_to_log(self.__ID, brand, plate_num)

                        # Returns results from user's choice (all cars, available cars or unavailable cars)
                        if self.__choice in ["1","2","3"]:
                            for car in self.cars:
                                plate_number = car.get_plate_number()
                                brand = car.get_brand()
                                location = car.get_location_string()
                                self.__salesman_menu.car_lists(plate_number, brand, location)
                                Page = 1
                            input("Press enter to continue ")

                elif choice == "5":
                    log = self.__salesman_service.get_log()
                    self.__salesman_menu.print_log(log)
                    Page = 1
                    input("Press enter to continue ")

                elif choice == "6":
                    new_pw = self.__salesman_menu.get_new_pw()
                    self.__salesman_service.change_pw(new_pw)
                    Page = 1
                    input("Press enter to continue ")
Exemplo n.º 8
0
class Rent_controller(object):
    def __init__(self):
        # UI's
        self.__rent_menu = Print_rent_menu()
        self.error = Print_error()
        # Services
        self.__Rent_service = Rent_service()
        # Validations
        self.__Rent_valid = Rent_validation()

    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.º 9
0
class Salesman_controller:
    def __init__(self):
        #Controllers
        self.__rent_controller = Rent_controller()
        self.__order_controller = Order_controller()
        #Services
        self.__salesman_service = Salesman_service()
        #UI
        self.__salesman_menu = Print_salesman_menu() 
        self.error = Print_error()
        #Utilizations
        self.__Salesman_valid = Salesman_validation()
        self.__get_format = Format_text()
        #Variables
        self.confirmation_str = ""
        self.menu = ""
        self.underline = ""
        
    def sign_in_page(self):
        """Gets employee's ID and password and checks if it's valid"""
        # Get ID
        self.menu = self.__get_format.log_in_format()
        self.__ID = self.__salesman_menu.ID_menu(self.menu)
        # Get password
        self.__password = self.__salesman_menu.password_menu(self.menu, self.__ID)
        # Check whether it's valid or not
        valid = self.__salesman_service.salesman_ID_pw(self.__ID,self.__password)
        if valid == False:
            try_again = input("\n\t\tID or password is invalid. Try again? (y/n): ").lower()
            return try_again, valid
        else:
            return "n", valid

    def salesman_menu(self): 
        Page = 1
        while 0 < Page < 4:           
            if Page == 1:
                # Prints Salesman menu
                self.menu, self.underline = self.__get_format.salesman_format()
                choice = self.__salesman_menu.salesman_main_page(self.menu, self.underline)
                Valid, Page = self.__Salesman_valid.Check_menu_choice(choice, Page)
                if Valid:
                    Page += 1 # Moves to next page
                elif Page == 0:
                    pass    # Moves to previous page
                elif Page != 4:
                    self.error.Wrong_salesmanmenu_choice() # Prints error message

            elif Page == 2:
                # Search for order
                if choice == "1":
                    Page = self.__order_controller.find_order_process(Page)

                # Get customer information
                elif choice == "2":
                    self.menu = self.__get_format.customer_info_format()
                    self.email = self.__salesman_menu.customer_info_menu(self.menu)
                    Page = self.__Salesman_valid.Check_email_choice(self.email, Page)
                    if Page == 2:
                        customer = self.__salesman_service.get_customer(self.email)
                        if customer == None:
                            self.error.Wrong_email()
                        else:
                            orders = self.__salesman_service.order_string()
                            delete = self.__salesman_menu.customer_list(self.underline ,customer, orders)
                            if delete == "d":
                                self.__salesman_service.delete_customer(customer)
                                self.confirmation_str = "Customer"
                                action = "removed"
                                self.__salesman_service.delete_customer_to_log(self.__ID)
                                self.__salesman_menu.confirmation(self.confirmation_str, action)
                        
                # Get cars information
                elif choice == "3":
                    self.menu = self.__get_format.car_info_format()
                    self.__choice = self.__salesman_menu.cars_info_menu(self.menu, self.underline)
                    Valid, Page = self.__Salesman_valid.Check_cars_information_choice(self.__choice, Page)
                    if Valid:
                        pass    # Moves forward
                    elif Page == 1:
                        pass    # Moves to previous page
                    elif Page != 8:
                        self.error.Wrong_car_info_choice() # Prints error message

                    if Page == 2:
                        if self.__choice == "1":
                            self.cars = self.__salesman_service.get_all_cars()

                        elif self.__choice == "2":
                            self.cars = self.__salesman_service.get_available_cars()

                        elif self.__choice == "3":
                            self.cars = self.__salesman_service.get_unavailable_cars()

                        elif self.__choice == "4":
                            self.menu = self.__get_format.add_car_format()
                            plate_num, brand, size, location = self.__salesman_menu.add_car(self.menu)
                            if plate_num != "p":
                                self.__salesman_service.add_car_repo(plate_num, brand, size, location)
                                self.confirmation_str = "Car"
                                action = "added"
                                self.__salesman_menu.confirmation(self.confirmation_str, action)
                                # Add to log
                                self.__salesman_service.add_to_log(self.__ID, brand, plate_num)

                        # Returns results from user's choice (all cars, available cars or unavailable cars)
                        if self.__choice in ["1","2","3"]:
                            os.system("cls||clear")
                            self.menu = self.__get_format.car_list_format(self.__choice)
                            self.__salesman_menu.car_list_header(self.menu)
                            if self.cars != []:
                                for car in self.cars:
                                    plate_number = car.get_plate_number()
                                    brand = car.get_brand()
                                    location = car.get_location_string()
                                    self.__salesman_menu.car_lists(plate_number, brand, location)
                                    Page = 1
                                input("\n\t\t\tPress enter to continue ")
                            else:
                                self.__salesman_menu.no_cars()
                                input("\n\t\t\tPress enter to continue ")

                elif choice == "4":
                    self.menu = self.__get_format.log_format()
                    log = self.__salesman_service.get_log()
                    self.__salesman_menu.print_log(self.menu, self.underline, log)
                    Page = 1

                elif choice == "5":
                    self.menu = self.__get_format.password_format()
                    new_pw = self.__salesman_menu.get_new_pw(self.menu)
                    self.__salesman_service.change_pw(new_pw)
                    Page = 1
                    input("\n\t\t\tPress enter to continue ")
Exemplo n.º 10
0
class Rent_controller(object):
    def __init__(self):
        # UI's
        self.__rent_menu = Print_rent_menu()
        self.error = Print_error()
        # Services
        self.__Rent_service = Rent_service()   
        # Validations
        self.__Rent_valid = Rent_validation() 

    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 = 0   # If user inputs correctly he will go on next page
        # While loop used so the user can navigate back and forth in the system
        while Page < 7: # Stops running when user has completed the rental process
            if Page == 0:
                # 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
                elif Page == 0:
                    Page = 7
                else:
                    self.error.Wrong_location() # Prints error message
            elif Page == 1:
                # Open date option menu - Returns pick up- and drop off dates - Checks if correct input
                self.date_list = self.__rent_menu.Page_2()
                Valid, Page = self.__Rent_valid.Check_date(self.date_list, Page)
                if Valid:
                    Page += 1
                elif Page == 0:
                    pass    # Moves to previous page
                else:
                    self.error.Wrong_date() # Prints error message
            elif Page == 2:
                # 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
                elif Page == 1:
                    pass    # Moves to previous page
                else:
                    self.error.Wrong_vehicle_size() # Prints error message
            elif Page == 3:
                # Finds available cars using information from the user
                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()
                # 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, Page)
                if Valid:
                    Page += 1
                elif Page == 2:
                    pass    # Moves to previous page
                else:
                    self.error.Wrong_car_choice()   # Prints error message 
            elif Page == 4:
                # Use the self.car_choice to find the desired car in the car list and makes a car object in service
                # This definition does not return anything, it makes a self.obj used in the desired_car_info in Rent_service
                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
                elif Page == 3:
                    pass    # Moves to previous page
                else:
                    self.error.Wrong_car_choice()   # Prints error message 
            elif Page == 5:
                # 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 Valid:
                    choice = self.__rent_menu.Page_6()
                    Valid, Page = self.__Rent_valid.Check_feature(choice, Page)
                    self.__Rent_service.add_features(choice)
                if Valid:
                    Page += 1
                elif Page == 4:
                    pass    # Moves to previous page
                else:
                    self.error.Wrong_feature_choice()   # Prints error message