コード例 #1
0
class Overview_Service:
    def __init__(self):
        self.__cars_repo = Car_Repo()
        self.__booking_repo = Booking_Repo()
    
    def overview_check(self, choice):
        if choice not in range(1,4):
            raise Exception

    def get_customer(self,custom_email):
        # if custom_email:
        #     raise Exception
        # else: 
        #     self.__booking_repo.look_up_customer(custom_email)
        #hér þarf að laga villutékk fyrir look up customer. 

    def car_menu_check(self, choice):
        if choice not in range (1,6):
            raise Exception

    def get_cars(self, car_choice):
        return self.__cars_repo.show_available_cars(car_choice)
    
    def valid_license_plate(self, car_choice, license_number):
        self.__cars_repo.look_up_car(car_choice, license_number)
        if license_number == False:
            raise Exception
コード例 #2
0
ファイル: car_service.py プロジェクト: sarabry17/car-rental
class Car_Service:
    def __init__(self):
        self.__car_repos = Car_Repo()

    def add_cars(self, cars):
        if self.is_valid_car(cars):
            self.__car_repos.add_cars(cars)

    def is_valid_car(self, cars):
        return True

    # def get_cars(self):
    #     return self.__car_repos.get_cars()

    #cb = create booking.
    def cb_show_available_cars(self, inp_car_type):
        return self.__car_repos.cb_show_available_cars(inp_car_type)
コード例 #3
0
class Car_Service:

    def __init__(self):
        self.__car_repos = Car_Repo()

    def add_cars(self, cars):
        if self.is_valid_car(cars):
            self.__car_repos.add_cars(cars)
    
    def is_valid_car(self, cars):
        return True

    
    #cb = create booking.
    def cb_show_available_cars(self, inp_car_type):
        return self.__car_repos.cb_show_available_cars(inp_car_type)

    
    def cb_show_cancel_car(self,name):
        return self.__car_repos.show_cancelled_rented_car(name)

    def cb_cancel_available(self,license_num):
        return self.__car_repos.cancel_available(license_num)


    def car_choice(self, car_pick,start_date,tday_str):
        if car_pick == False:
            raise Exception
        self.__car_repos.mark_as_rented(car_pick,start_date,tday_str)
コード例 #4
0
ファイル: admin_ui.py プロジェクト: sarabry17/car-rental
 def mark_repair(self):
     print("Choose action: ")
     repair_choice = input("1. Mark in repair\n2. Mark out of repair\n ")
     repeat = "y"
     sure = "n"
     while repeat == "y":
         while sure == "n":
             license_num = input(
                 "Pleace enter the License plate number of car to mark for repair: "
             ).upper()
             sure = input(
                 "Are you sure you want to mark {0} unavalible due to repair? (y/n) "
                 .format(license_num)).lower()
             repeat = input(
                 "Would you like to mark anathor car for repair? (y/n) "
             ).lower()
     getting = Car_Repo()
     getting.mark_repair(repair_choice, license_num)
コード例 #5
0
ファイル: admin_ui.py プロジェクト: sarabry17/car-rental
    def remove_car(self):
        #Header
        print("ADMIN/Remove car")
        print("-" * 20)
        # Validation tests need to be added in admin_service
        license_num = input(
            "Please enter license plate number of car to remove from system: "
        ).upper()
        confirm = input(
            "Are you sure you want to remove {} from system? (y/n) ".format(
                license_num)).lower()

        print("{} has been removed from system".format(license_num.upper()))
        print("")

        again = input("Do you want to remove another car? (y/n)")
        getting = Car_Repo()
        getting.remove_car(license_num)
コード例 #6
0
 def __init__(self):
     self.car_repo = Car_Repo()
     self.booking_repo = Booking_Repo()
コード例 #7
0
class Dealer_service:
    def __init__(self):
        self.car_repo = Car_Repo()
        self.booking_repo = Booking_Repo()

    def home_check(self, choice):
        if choice not in range(1,6):
            raise Exception

    def option_check(self,contin):
        if contin != "1" and contin != "2":
            raise Exception

    #cb = Create booking. 
    def cb_check_name(self,first_name_alpha, last_name_alpha):       
        if first_name_alpha == False or last_name_alpha == False: 
            raise Exception

    def cb_check_driver_license(self, driver_license):
        driver = driver_license.isnumeric()
        len_driver_license = len(driver_license)
        if driver == False or len_driver_license != 9:
            raise Exception
        
    def cb_check_email(self,email):
        for letter in email: 
            if letter == "@": 
                email = True
                break
            else:
                email = False
        
        if email == False:
            raise Exception
    
    def cb_check_phone(self, phone_num):
        if phone_num == False:
            raise Exception

    def cb_check_card_num(self, card_num):
        len_card_num = len(card_num)
        card_num_numeric = card_num.isnumeric()
        if len_card_num < 16 or len_card_num > 16:
            raise Exception
        if card_num_numeric == False:
            raise Exception
    
    def create_booking_check_card_valid_time(self,start_date):
        if len(start_date) == 10:
            day = start_date[0:2] 
            month = start_date[3:5]
            year = start_date[6:]
        elif len(start_date) == 8:
            day = start_date[0]
            month = start_date[2]
            year = start_date[4:]
        if day not in range(1,32) or month not in range(1,13) or year < 2018:
            raise Exception

    def check_if_card_is_valid(self, validation_date): 
        tday = datetime.datetime.today()
        dt = datetime.datetime.strptime(validation_date, "%m/%y")
        end_date = dt - tday
        difference = end_date.days
        if difference < 0:
            raise Exception

    def cb_check_cvc(self,cvc):
        len_cvc = len(cvc)
        cvc_numeric = cvc.isnumeric()
        if len_cvc < 3 or len_cvc > 3: 
            raise Exception
        if cvc_numeric == False:
            raise Exception

    def valid_return(self, license_num):
        if license_num == False:
            raise Exception
        self.car_repo.return_rental(license_num)

    #Extras menu.
    def extras_menu_check(self,extras_option):
        if extras_option not in range (1,5):
            raise Exception 

    #Change booking.
    def change_check(self, change_choice):
        if change_choice not in range (1,4):
            raise Exception


#Edit booking.
    def edit_name(self, name):
        if name == False:
            raise Exception
        self.booking_repo.look_up_customer_by_name(name)#Kalla á fall sem les bara skrá enn breytir ekki.

    def edit_menu_check(self, edit_choice):
        if edit_choice not in range (1,6):
            raise Exception

    def edit_name_check(self,name,edit_name):
        self.booking_repo.edit_booking_name(name, edit_name)

    def edit_drivers_license_check(self,name,edit_drivers_license):
        self.booking_repo.edit_booking_driver_license(name, edit_drivers_license)

    def edit_email_check(self, name, edit_email):
        self.booking_repo.edit_booking_email(edit_email,name)

    def edit_phone_number(self,name,edit_phone_number):
        #Á eftir að gera villu check
        #Sigga
        self.booking_repo.edit_booking_phone_number(name, edit_phone_number)
    
    def edit_credit_card_insurance_check(self,edit_credit_card_info,name):
        self.booking_repo.edit_booking_credit_card_insurance(edit_credit_card_info,name)

    #Cancel booking.
    def cancel_check(self, name):
        if name == False:
            raise Exception
        self.booking_repo.cancel_booking(name)

    #Adding booking.
    def add_booking(self, booking):
        self.booking_repo.add_booking(booking)

    #check date.
    def obtain_date(self,start_date): 
         date_c = datetime.datetime.strptime(start_date, "%d/%m/%Y")
         if date_c == False:
             raise Exception
コード例 #8
0
 def __init__(self):
     self.admin_service = Admin_service()
     self.__car_service = Car_Service()
     self.car_repo = Car_Repo()
コード例 #9
0
class Admin_Ui:
    def __init__(self):
        self.admin_service = Admin_service()
        self.__car_service = Car_Service()
        self.car_repo = Car_Repo()

    def admin_home_page(self):
        """interface that admin can access"""
        #Header
        print("ADMIN")
        print("-" * 20)

        print("Choose action: ")

        choice = 7
        while choice not in range(1, 5):
            try:
                choice = int(
                    input(
                        "1. Create new car\n2. Remove car\n3. Mark car for repair\n4. Log out\n "
                    ))
                print("")
                self.admin_service.home_check(choice)
            except:
                print("Invalid action, please select number from 1 to 4")
                print("")
        return choice

    def remove_car(self):
        #Header
        print("ADMIN/Remove car")
        print("-" * 20)

        confirm = "y"
        while confirm == "y":
            license_num = input(
                "Please enter license plate number of car to remove from system: "
            ).upper()

            confirm_inp = "a"
            no_fails = True
            while no_fails:
                try:
                    if confirm_inp not in "yn":
                        confirm_inp = input(
                            "Are you sure you want to remove {} from system? (y/n) "
                            .format(license_num)).lower()
                        self.admin_service.y_and_n_validation(confirm_inp)
                        if confirm_inp == "y":
                            print("{} has been removed from system\n".format(
                                license_num.upper()))
                            self.car_repo.remove_car(license_num)
                        elif confirm_inp == "n":
                            break
                    elif confirm_inp == "y" or confirm_inp == "n":
                        again = input(
                            "Do you want to remove another car? (y/n)")
                        self.admin_service.y_and_n_validation(again)
                        if again == "y":
                            confirm_inp = "a"
                            break
                        if again == "n":
                            no_fails = False
                            confirm = "n"
                except:
                    print("Please use 'y' or 'n' to confirm!")

    def mark_repair(self):
        print("Choose action: ")
        repair_choice = input("1. Mark in repair\n2. Mark out of repair\n ")
        repeat = "y"
        sure = "n"
        while repeat == "y":
            while sure == "n":
                license_num = input(
                    "Pleace enter the License plate number of car to mark for repair: "
                ).upper()
                sure = input(
                    "Are you sure you want to mark {0} for repair? (y/n) ".
                    format(license_num)).lower()
                repeat = input(
                    "Would you like to mark another car for repair? (y/n) "
                ).lower()
        self.car_repo.mark_repair(repair_choice, license_num)

    def create_car_page(self):
        print("ADMIN/Create new car")
        print("-" * 20)

        confirm = "y"

        while confirm == "y":

            license_num = input("Please enter license plate number: ")

            car_type = " "
            while car_type not in "ABC":
                try:
                    car_type = input(
                        "Please enter car type (A, B, C) :").upper()
                    self.admin_service.car_type_check(car_type)
                except:
                    print(
                        "Available types are A, B or C. Please choose one of those types!"
                    )
            print("")

            #initiate variables:
            confirm_inp = "a"
            no_fails = True
            while no_fails:
                try:
                    if confirm_inp not in "yn":
                        confirm_inp = input(
                            "Confirm this car registration? (y/n) ")
                        print("")
                        self.admin_service.y_and_n_validation(confirm_inp)
                        if confirm_inp == "y":
                            print("The car {} has been added to system.\n".
                                  format(license_num.upper()))
                        elif confirm_inp == "n":
                            break
                    elif confirm_inp == "y" or confirm_inp == "n":
                        again = input(
                            "Would you like to add another car? (y/n)")
                        self.admin_service.y_and_n_validation(again)
                        if again == "y":
                            return license_num, car_type, confirm, again
                        if again == "n":
                            no_fails = False
                            confirm = "n"
                except:
                    print("Please use 'y' or 'n' to confirm!")

        print("")
        return license_num, car_type, confirm, again

    def counter_added_cars(self, counter):
        print("You have added {} car/s to the system.".format(counter))

    def create_the_car(self, license_num, car_type, price, status="Available"):
        new_car = Car(license_num, car_type, price, status)
        self.__car_service.add_cars(new_car)
コード例 #10
0
 def __init__(self):
     self.__overview_service = Overview_Service()
     self.car_repo = Car_Repo()
コード例 #11
0
class Overview_Ui:
    def __init__(self):
        self.__overview_service = Overview_Service()
        self.car_repo = Car_Repo()

    def overview_menu(self):
        """the overview menu where the dealer can choose what he wants to review and see"""
        print("Dealer / Overview")
        print("-" * 20)
        choice = 7
        while choice not in range(1, 4):
            try:
                print("Please choose 1, 2 or 3.")
                choice = int(
                    input(
                        "1. Look up customer\n2. Car information\n3. Go to homepage\n"
                    ))
                self.__overview_service.overview_check(
                    choice)  #hér þarf að runna í service fallinu.
            except:
                print("Not a valid option, please select number from 1 to 3")
                print("")
        return choice

    def look_up_customer(self):
        email = False
        while email == False:
            try:
                print("")
                email = input(
                    "Please enter email of customer to find in system: ")
                print("")
                self.__overview_service.get_customer(email)
                print("")
                email = True
            except:
                print("Not a valid email, please enter a valid email.")
                print("")

    def car_overview(self):
        # elif choice == "2":
        car_choice = 7
        while car_choice not in range(1, 6):
            try:
                print("Choose action:")
                print("")
                car_choice = int(
                    input(
                        "1. Show all available cars\n2. Show rented cars\n3. Look up a specific car\n4. Show price list\n5. Go to homepage\n"
                    ))
                self.__overview_service.car_menu_check(
                    car_choice
                )  #hér þarf að kalla í eitthvað í service fallinu
            except:
                print("Not a valid option, please select number from 1 to 5")
                print("")
        return car_choice

    def get_car(self, car_choice):
        print("{:<15}{:<6}{:<7}{:<10}".format("License plate", "Type", "Price",
                                              "Status"))
        print("-" * 36)
        self.car_repo.show_available_cars(car_choice)

#Það virkaði ekki að nota try og except en þetta virkar svona og settum aðeins öðruvísi villucheck

    def specific_car_input(self, car_choice):
        license_num = False
        while license_num == False:
            # try:
            print("")
            license_number = input("Insert license plate: ").upper()
            print("")
            self.__overview_service.valid_license_plate(
                car_choice, license_number)
            license_num = True
            print("")
            # except:
            # print("License plate number does not exist in the system, please enter a valid number.")
            # print("")
        return license_number

    def show_price_list(self):
        print("Prices are per day.")
        print(" " * 2, "Type A", " " * 8, "Type B", " " * 8, "Type C", " " * 2)
        print("-" * 44)
        print(" " * 2, "$4000", " " * 9, "$3000", " " * 9, "$2000", " " * 2)
        print("")
        print("Extras:")
        print("")
        print("Kasko insurance ($50)\nChild seat ($1)")
        print("")
コード例 #12
0
ファイル: car_service.py プロジェクト: sarabry17/car-rental
 def __init__(self):
     self.__car_repos = Car_Repo()
コード例 #13
0
class Dealer_service:
    def __init__(self):
        self.car_repo = Car_Repo()
        self.booking_repo = Booking_Repo()

    def home_check(self, choice):
        if choice not in range(1, 6):
            raise Exception

    #cb = Create booking.
    def cb_check_name(self, first_name_alpha, last_name_alpha):
        if first_name_alpha == False or last_name_alpha == False:
            raise Exception

    def cb_check_driver_license(self, driver):
        if driver == False:
            raise Exception

    def cb_check_email(self, email):
        for letter in email:
            if letter == "@":
                email = True
                break
            else:
                email = False

        if email == False:
            raise Exception

    def cb_check_phone(self, phone_num):
        if phone_num == False:
            raise Exception

    def cb_check_card_num(self, card_num):
        len_card_num = len(card_num)
        card_num_numeric = card_num.isnumeric()
        if len_card_num < 16 or len_card_num > 16:
            raise Exception
        if card_num_numeric == False:
            raise Exception

    def check_if_card_is_valid(self, validation_date):
        tday = datetime.datetime.today()
        dt = datetime.datetime.strptime(validation_date, "%m/%y")
        end_date = dt - tday
        difference = end_date.days
        if difference < 0:
            raise Exception

    def cb_check_cvc(self, cvc):
        len_cvc = len(cvc)
        cvc_numeric = cvc.isnumeric()
        if len_cvc < 3 or len_cvc > 3:
            raise Exception
        if cvc_numeric == False:
            raise Exception

    def valid_return(self, license_num):
        if license_num == False:
            raise Exception
        self.car_repo.return_rental(license_num)

    #Change booking.
    def change_check(self, change_choice):
        if change_choice not in range(1, 4):
            raise Exception

    def edit_check(self):
        pass

    def cancel_check(self, name):
        if name == False:
            raise Exception
        self.booking_repo.cancel_booking(name)
コード例 #14
0
 def __init__(self):
     self.__cars_repo = Car_Repo()
     self.__booking_repo = Booking_Repo()