def __init__(self):
     #Services
     self.info_service = Information_service()
     #UIs
     self.__information_menu = Print_information()
     #Utilizations
     self.__get_format = Format_text()
     #Variables
     self.menu = ""
Beispiel #2
0
def main():
    os.system("cls||clear")
    print_art_page = Arts()
    print_art_page.get_happy_wheels()
    print_art_page.get_car()
    get_format = Format_text()
    start_program = Main_controller()
    header, main_menu, choices, underline = get_format.main_menu_format()
    start_program.Main_page(header, main_menu, choices, underline)
Beispiel #3
0
 def __init__(self):
     #Controllers
     self.__rent_controller = Rent_controller()
     self.__salesman_controller = Salesman_controller()
     self.__order_controller = Order_controller()
     self.__information_controller = Information_controller()
     #UI
     self.__main_menu = Print_main_menu()
     #Utilizations
     self.__get_format = Format_text()
 def __init__(self):
     #Services
     self.__find_service = Find_order_service()
     #UI
     self.__menu = Print_find_order_menu()
     #Utilizations
     self.__Salesman_valid = Salesman_validation()
     self.__get_format = Format_text()
     #Variables
     self.menu = ""
     self.underline = ""
Beispiel #5
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 = ""
Beispiel #6
0
class Main_controller:
    def __init__(self):
        #Controllers
        self.__rent_controller = Rent_controller()
        self.__salesman_controller = Salesman_controller()
        self.__order_controller = Order_controller()
        self.__information_controller = Information_controller()
        #UI
        self.__main_menu = Print_main_menu()
        #Utilizations
        self.__get_format = Format_text()

    def main_page(self):
        """Reads choice and directs on a path depending on input"""
        choice = ""
        while choice != "x":
            header, main_menu, choices, underline = self.__get_format.main_menu_format(
            )
            choice = self.__main_menu.main_page(header, main_menu, choices,
                                                underline)
            if choice == "1":
                self.__rent_controller.Rent_page()
            elif choice == "2":
                try_again = ""
                while try_again != "n":
                    try_again, valid = self.__salesman_controller.sign_in_page(
                    )
                if valid == True:
                    self.__salesman_controller.salesman_menu()
            elif choice == "3":
                self.__order_controller.find_order_process(page=2)
            elif choice == "i":
                self.__information_controller.information_page()
class Information_controller(object):
    def __init__(self):
        self.__information_menu = Print_information()
        self.info_service = Information_service()
        self.__get_format = Format_text()
        self.menu = ""

    def information_page(self):
        choice = ""
        while choice != "p":
            self.menu = self.__get_format.info_format()
            choice = self.__information_menu.information_main_page(self.menu)
            if choice == "a":
                self.__information_menu.car_rental_agreement()
                input("Press enter to continue.")

            elif choice == "b":
                self.__information_menu.terms_and_conditions()
                input("Press enter to continue.")

            elif choice == "c":
                self.__information_menu.quality_policy()
                input("Press enter to continue.")

            elif choice == "d":
                salesman_dict = self.info_service.get_salesman_dict()
                self.__information_menu.print_salesman_header()
                for ID, salesman in salesman_dict.items():
                    name = salesman.get_name()
                    email = salesman.get_email()
                    self.__information_menu.print_salesman(name, email, ID)
                input("Press enter to continue.")
class Order_controller:
    def __init__(self):
        # UI's
        self.__menu = Print_find_order_menu()
        # Services
        self.__find_service = Find_order_service()
        # Validations
        self.__Salesman_valid = Salesman_validation()
        #Utilizations
        self.__get_format = Format_text()
        #Variables
        self.menu = ""
        self.underline = ""

    def find_order_process(self, page):
        """ Finds order from user's input and deletes it from the database """
        self.menu, self.underline = self.__get_format.find_order_format()
        order_num = self.__menu.find_by_num(self.menu)
        Page = self.__Salesman_valid.Check_navigation(order_num, page)

        if Page == 2:
            order = self.__find_service.get_order(order_num)
            if order != None:
                choice = self.__menu.print_order(self.underline, order)
                if choice == "d":
                    self.__find_service.delete_order(order_num)
                    self.__menu.confirmation()
            else:
                self.__menu.No_match(order_num)
            return Page
        else:
            return Page
Beispiel #9
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 = ""
class Information_controller:
    def __init__(self):
        #Services
        self.info_service = Information_service()
        #UIs
        self.__information_menu = Print_information()
        #Utilizations
        self.__get_format = Format_text()
        #Variables
        self.menu = ""

    def information_page(self):
        """Reads choice and directs to right path depending on input"""
        choice = ""
        while choice not in ["p", "m"]:
            self.menu = self.__get_format.info_format()
            choice = self.__information_menu.information_main_page(self.menu)

            #Rental Agreement
            if choice == "1":
                self.__information_menu.car_rental_agreement()
                input("\nPress enter to continue.")

            #Terms and conditions
            elif choice == "2":
                self.__information_menu.terms_and_conditions()
                input("\nPress enter to continue.")

            #Quality Policy
            elif choice == "3":
                self.__information_menu.quality_policy()
                input("\nPress enter to continue.")

            #Uses salesman dict to return a dict of salesmen
            elif choice == "4":
                salesman_dict = self.info_service.get_salesman_dict()
                self.__information_menu.print_salesman_header()
                for ID, salesman in salesman_dict.items():
                    name = salesman.get_name()
                    email = salesman.get_email()
                    self.__information_menu.print_salesman(name, email, ID)
                input("\nPress enter to continue.")

            elif choice == "x":
                exit()
 def __init__(self):
     self.__information_menu = Print_information()
     self.info_service = Information_service()
     self.__get_format = Format_text()
     self.menu = ""
Beispiel #12
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()
        # Utilizations 
        self.get_format = Format_text()
        # Variables
        self.menu = ""
        self.page = ""
        self.choices = ""
        self.underline = ""

    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.menu, self.page, self.choices, self.underline = self.get_format.loc_format()
                self.location = self.__rent_menu.Page_1(self.menu, self.page, self.choices, self.underline)                
                Valid, Page = self.__Rent_valid.Check_location(self.location, Page)
                if Valid:
                    Page += 1   # Moves to next page
                elif Page == 0:
                    pass
                elif Page != 13:
                    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.menu, self.page = self.get_format.date_time_format()
                self.__date_str_list = self.__rent_menu.Page_2(self.menu, self.page)
                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)
                # If user goes back to this page then available_car_string gets resetted
                available_car_string = ""
                # Open size option menu - Returns size of car - Checks if correct input
                self.menu, self.page, self.choices = self.get_format.car_format()
                self.vehicle_size = self.__rent_menu.Page_3(self.menu, self.page, self.choices, self.underline)
                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(self.menu, self.page, 
                self.underline, 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.menu, self.page, self.underline, 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:
                    self.menu, self.page = self.get_format.feature_format()
                    choice = self.__rent_menu.Page_6(self.menu, self.page, self.underline)
                    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)
                self.menu, self.page = self.get_format.order_format()
                choice = self.__rent_menu.Page_7(self.menu, self.page, self.underline, 
                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:
                    self.menu, self.page = self.get_format.personal_info_format(self.section_valid)
                    personal_info_list_1 = first_name, last_name, date_of_birth, email, choice = self.__rent_menu.Page_8_1(self.menu, self.page, self.underline)
                    Valid, Page = self.__Rent_valid.Check_personal_info_1(personal_info_list_1, Page)
                elif self.section_valid == 1:
                    self.menu, self.page = self.get_format.personal_info_format(self.section_valid)
                    personal_info_list_2 = country, address, zip_code, phone, choice = self.__rent_menu.Page_8_2(self.menu, self.page, self.underline)
                    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.menu, self.page = self.get_format.payment_method_format()
                self.payment_choice = self.__rent_menu.Page_9(self.menu, self.page, self.underline)
                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
                    self.menu, self.page = self.get_format.card_info()
                    card, security_code, exp_date, choice = self.__rent_menu.Page_10_1(self.menu, self.page, self.underline)
                elif self.payment_choice == "3":         # Opens up credit card insurance menu
                    self.menu, self.page = self.get_format.insurance_info()
                    card, security_code, exp_date, choice = self.__rent_menu.Page_10_2(self.menu, self.page, self.underline)
                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
                self.menu, self.page = self.get_format.checkout_format()
                choice = self.__rent_menu.Page_11(self.menu, self.page, self.underline, 
                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.menu = self.get_format.receipt_format()
                self.__rent_menu.Page_12(self.menu, self.underline, booking_num)
                Page += 1
Beispiel #13
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 ")