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()
def __init__(self): # Menus self.__main_menu = Print_main_menu() # Controllers self.__rent_controller = Rent_controller() self.__salesman_controller = Salesman_controller() self.__order_controller = Order_controller() self.__information_controller = Information_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 __init__(self): # UI's self.__salesman_menu = Print_salesman_menu() # Controllers self.__rent_controller = Rent_controller() self.__order_controller = Order_controller() # Services self.__salesman_service = Salesman_service() # Variables self.confirmation_str = ""
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 Main_controller(object): def __init__(self): # Menus self.__main_menu = Print_main_menu() # Controllers self.__rent_controller = Rent_controller() self.__salesman_controller = Salesman_controller() self.__order_controller = Order_controller() self.__information_controller = Information_controller() def Main_page(self): choice = "" while choice != "x": choice = self.__main_menu.main_page() if choice == "1": self.__rent_controller.Rent_page() elif choice == "2": self.__salesman_controller.sign_in_page() elif choice == "3": self.__order_controller.cancel_order_process() elif choice == "i": self.__information_controller.information_page()
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 ")
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 ")
class Salesman_controller(object): def __init__(self): # UI's self.__salesman_menu = Print_salesman_menu() # Controllers self.__rent_controller = Rent_controller() self.__order_controller = Order_controller() # Services self.__salesman_service = Salesman_service() # Variables self.confirmation_str = "" 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 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 # Prints Salesman menu self.__option = self.__salesman_menu.salesman_main_page() # Get rent process if self.__option == "1": self.__rent_controller.Rent_page() # Search for order elif self.__option == "2": self.__order_controller.cancel_order_process() # Get customer information elif self.__option == "3": self.email = self.__salesman_menu.customer_info_menu() customer = self.__salesman_service.get_customer(self.email) if type(customer) is object: orders = self.__salesman_service.order_string() else: orders = "" 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 self.__option == "4": self.__choice = self.__salesman_menu.cars_info_menu() 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) 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) input("") elif self.__option == "5": log = self.__salesman_service.get_log() self.__salesman_menu.print_log(log) input("") elif self.__option == "6": new_pw = self.__salesman_menu.get_new_pw() self.__salesman_service.change_pw(new_pw) input("")