class Return_Rental: def __init__(self): self.__dealer_service = Dealer_service() def return_rental_ui(self): license_num = False while license_num == False: try: license_num = input("Insert license plate: ") self.__dealer_service.valid_return(license_num) print("{} has been returned".format(license_num.upper())) print("") license_num = True except: print( "License plate number does not exist in the system, please enter a valid number." ) print("") return license_num
class Change_Booking_Ui: def __init__(self): self.__dealer_service = Dealer_service() def change_booking_menu(self): change_choice = 7 while change_choice not in range(1, 4): try: print("Choose action:") print("") change_choice = int( input("1. Edit booking\n2. Cancel booking\n3. Go back\n")) self.__dealer_service.change_check( change_choice ) #hér þarf að kalla í eitthvað í service fallinu except: print("Not a valid option, please select number from 1 to 3") print("") return change_choice def edit_booking(self): pass def cancel_booking(self): name = False while name == False: try: print("Enter name of cancelling customer: ") first_name = input("First name: ") last_name = input("Last name: ") name = first_name.capitalize() + " " + last_name.capitalize() self.__dealer_service.cancel_check( name) # kalla í service fall print("{} booking has been cancelled".format(name)) print("") name = True except: print( "This name does not exist in the system, please try again." ) print("") return name
def __init__(self): self.dealer_service = Dealer_service() self.__car_service = Car_Service() self.admin_service = Admin_service()
class Dealer_Ui: def __init__(self): self.dealer_service = Dealer_service() self.__car_service = Car_Service() self.admin_service = Admin_service() def home_page(self): #Header: print("DEALER") print("-" * 20) choice = 7 while choice not in range(1, 6): try: print("Please choose an action: ") choice = int( input( "1. Create booking\n2. Change booking\n3. Return rental\n4. Overview\n5. Log out\n" )) print("") self.dealer_service.home_check(choice) except: print("Not a valid option, please select number from 1 to 5") print("") return choice def create_booking_1_of_5(self): """creates both the customer and his booking, this is the first page of five in this process""" #Header: print("DEALER/ Create booking") print("-" * 20) print("(1 of 5)") last_name_alpha = False first_name_alpha = False while first_name_alpha == False or last_name_alpha == False: try: first_name = input("Enter first name: ").capitalize() last_name = input("Enter last name: ").capitalize() first_name_alpha = first_name.isalpha() last_name_alpha = last_name.isalpha() self.dealer_service.cb_check_name(first_name_alpha, last_name_alpha) except: print( "Name cannot include numbers or spaces, please enter first name and last name seperately!" ) print("") driver = False while driver == False: try: driver_license = input( "Enter customer driver license number: ") self.dealer_service.cb_check_driver_license(driver_license) driver = True except: print( "Driver license needs to be all digits and 9 characters, please try again!" ) print("") email = False while email == False: try: email = input("Enter the customer email: ") self.dealer_service.cb_check_email(email) except: print("Email needs to include '@', please try again!") print("") email = False phone_num = False while phone_num == False: try: phone_num = input("Enter the customer phone number: ") phone_num_check = phone_num.isnumeric() self.dealer_service.cb_check_phone(phone_num_check) except: print( "Phone number needs to be all numbers, please try again!\n" ) print("") return first_name, last_name, driver_license, email, phone_num def confirm_customer(self, first_name, last_name): unconfirmed = True while unconfirmed: try: confirm = input("Confirm customer information? (y/n)".lower()) self.admin_service.y_and_n_validation(confirm) unconfirmed = False except: print("Please use 'y' or 'n' to confirm!") if confirm == "y": print("{} {} has been added to system\n".format( first_name.capitalize(), last_name.capitalize())) return confirm def options(self): print("Options: ") no_ecxeption = True while no_ecxeption: try: contin = input("1. Continue\n2. Go to homepage\n") self.dealer_service.option_check(contin) no_ecxeption = False except: print("Available choices are 1 or 2, please try again!") print("") return contin def create_booking_2_of_5(self, name): #Header: print("DEALER/ Create booking") print("-" * 20) print("(2 of 5)") print("The insurance of the rent\n") card_not_valid = True #SARA while card_not_valid: card = False while card == False: try: card_num = input("Enter the card number : ") self.dealer_service.cb_check_card_num(card_num) card = True except: print( "Card number has 16 numbers, please do not use space or '-' between numbers." ) is_valid = False while is_valid == False: try: validation_date = input( "Enter the validation time (M/YY): ") self.dealer_service.check_if_card_is_valid(validation_date) is_valid = True card_not_valid = False except: print( "Card is outdated or wrongly inserted please use M/YY format, please try again!" ) card_not_valid = True is_valid = True cvc = False while cvc == False: try: cvc_num = input( "Enter CVC (three numbers positioned on the back of the card): " ) self.dealer_service.cb_check_cvc(cvc_num) cvc = True except: print( "The cvc is three digits, all numbers, please try again!\n" ) print("Card information has been saved for {}\n".format(name)) return card_num, validation_date, cvc def create_booking_3_of_5(self): #Header: print("DEALER/ Create booking") print("-" * 20) print("(3 of 5)") print("Please select date\n") no_fail_in_start_date = True while no_fail_in_start_date: try: #The end date is calculated in the main.py start_date = input("Enter start date (D/M/YYYY): ") self.dealer_service.obtain_date(start_date) no_fail_in_start_date = False except: print( "Please make sure you typed in correct date, note that you have to use this format D/M/YYYY" ) amount_of_days = int(input("Amount of days: ")) print("") inp_car_type = " " while inp_car_type not in "ABC": try: inp_car_type = input( "Car type A = $4000 \nCar type B = $3000 \nCar type C = $2000\nSelect a car type (A, B, C): " ).upper() print("") self.admin_service.car_type_check(inp_car_type) except: print( "Available types are A, B or C. Please choose one of those types!\n" ) return start_date, amount_of_days, inp_car_type def print_end_date(self, end_date): print("Return day: ", end_date) def create_booking_4_of_5(self, inp_car_type): #Header: print("DEALER/ Create booking/ Show all available cars") print("-" * 20) print("(4 of 5)\n") print("Print available cars\n") print("{:<13}{:<6}{:<7}{:<10}".format("Car lic.", "Type", "Price", "Car status")) print("-" * 36) self.__car_service.cb_show_available_cars(inp_car_type) print("") #Picking a car from the list that is printed. This will then change the status in the car csv def picking_car(self, start_date): car_picking = False while car_picking == False: try: car_pick = input("Select car: ").upper() tday = datetime.datetime.today() tday_str = tday.strftime("%d/%m/%Y") self.__car_service.car_choice(car_pick, start_date, tday_str) #bætti start_date við car_picking = True except: print("Car does not excist.") return car_pick def extras(self): extras_option = 4 while extras_option in range(1, 5): # try: print("Extras: ") extras_option = input( "1. Kasko insurance\n2. Child seat\n3. Kasko insurance and child seat\n4. No extras\n" ) print("") # self.dealer_service.extras_menu_check(extras_option)#kalla á service fall # except: # print("Please choose a valid option or number from 1 to 4") # print("") return extras_option def create_booking_5_of_5(self): #Header: print("DEALER/ Create booking/ Billing type") print("-" * 20) print("(5 of 5)\n") print("Please choose billing type\n") billing_type = input( "1. Credit or debit card\n2. Billing to\n3. Cash\n4. Go to home page\n" ) return billing_type def credit_debit_card(self): card_name = input("Enter name of carholder: ") card_not_valid = True #SARA while card_not_valid: card = False while card == False: try: card_num = input("Enter the card number : ") self.dealer_service.cb_check_card_num(card_num) card = True except: print( "Card number has 16 numbers, please do not use space or '-' between numbers." ) is_valid = False while is_valid == False: try: validation_time = input("Enter validation time (M/YY): ") self.dealer_service.check_if_card_is_valid(validation_time) is_valid = True card_not_valid = False except: print( "Card is outdated or wrongly inserted please use M/YY format, please try again!" ) card_not_valid = True is_valid = True return card_name, card_num, validation_time def confirm_billing(self): confirm = input("Confirm payment? (y/n): ") if confirm == "y": print("Your payment has been made.") elif confirm == "n": print( "You didn't confirm the payment, you'll be transported back to choose a billing type.\n" ) return confirm def billing_to(self): comp_name = input("Enter name of company: ") return comp_name def cash(self, total_amount): print("Amount due: {}\n".format(total_amount)) paid_amount = input("Enter amount paid: ") return paid_amount def print_change(self, change): print("Change: {}".format(change)) def create_booking_6_of_5_recipt(self, name, driver_license, email, phone_num, price, extras_option, total_price, car_pick, amount_of_days): print("{:<20} {:<21} {:<20} {:<15} {:<10}".format( "Name", "Driver license number", "Car license plate", "Email", "Phone number")) print("-" * 95) print("{:<20} {:<21} {:<20} {:<15} {:<10}".format( name, driver_license, car_pick, email, phone_num)) print("-" * 95) if extras_option == "Kasko insurance": extras_amount = 50 elif extras_option == "Child seat": extras_amount = 1 elif extras_option == "Kasko insurance & child seat": extras_amount = 51 elif extras_option == "No extras": extras_amount = 0 print("Price per day: ${:>}".format(price)) print("Extras: ${:>}".format(extras_amount * amount_of_days)) print("Total Price: ${:>}\n".format(total_price)) def create_the_booking(self, name, driver_license, email, phone_num, card_insurance, start_date, end_date, car_pick, car_type, total_price, extras, payment_type, booking_status="New"): send = Booking(name, driver_license, email, phone_num, card_insurance, start_date, end_date, car_pick, car_type, total_price, extras, payment_type, booking_status) self.dealer_service.add_booking(send)
def __init__(self): self.__dealer_service = Dealer_service()
class Dealer_Ui: def __init__(self): self.dealer_service = Dealer_service() self.__car_service = Car_Service() self.admin_service = Admin_service() def home_page(self): #Header: print("DEALER") print("-" * 20) choice = 7 while choice not in range(1, 6): try: print("Please choose an action: ") choice = int( input( "1. Create booking\n2. Change booking\n3. Return rental\n4. Overview\n5. Log out\n" )) print("") self.dealer_service.home_check(choice) except: print("Not a valid option, please select number from 1 to 5") print("") return choice def create_booking_1_of_5(self): """creates both the customer and his booking, this is the first page of five in this process""" #Header: print("DEALER/ Create booking") print("-" * 20) print("(1 of 5)") last_name_alpha = False first_name_alpha = False while first_name_alpha == False or last_name_alpha == False: try: first_name = input("Enter first name: ").capitalize() last_name = input("Enter last name: ").capitalize() first_name_alpha = first_name.isalpha() last_name_alpha = last_name.isalpha() self.dealer_service.cb_check_name(first_name_alpha, last_name_alpha) except: print( "Name cannot include numbers or spaces, please enter first name and last name seperately!" ) print("") driver = False while driver == False: try: driver_license = input("Enter a driver's license number: ") driver = driver_license.isnumeric() self.dealer_service.cb_check_driver_license(driver) except: print( "Driver license needs to be all digits and 9 characters, please try again!" ) print("") email = False while email == False: try: email = input("Enter the clients email: ") self.dealer_service.cb_check_email(email) except: print("Email needs to include '@', please try again!") print("") email = False phone_num = False while phone_num == False: try: phone_num = input("Enter the customers phone number: ") phone_num = phone_num.isnumeric() self.dealer_service.cb_check_phone(phone_num) except: print( "Phone number needs to be all numbers, please try again!\n" ) print("") return first_name, last_name, driver_license, email, phone_num def confirm_customer(self, first_name, last_name): confirm = input("Confirm customer information? (y/n)".lower()) if confirm == "y": print("{} {} has been added to system\n".format( first_name.capitalize(), last_name.capitalize())) elif confirm == "n": print("Please choose action from the options list\n.") return confirm def options(self): print("Options: ") contin = input("1. Continue\n2. Go back\n3. Go to homepage\n") print("") return contin def create_booking_2_of_5(self, name): #Header: print("DEALER/ Create booking") print("-" * 20) print("(2 of 5)") print("The insurance of the rent\n") card = False while card == False: try: card_num = input("Enter the card number : ") self.dealer_service.cb_check_card_num(card_num) card = True except: print( "Card number has 16 numbers, please do not use space or '-' between numbers." ) is_valid = False while is_valid == False: try: validation_date = input("Enter the validation time (M/YY): ") self.dealer_service.check_if_card_is_valid(validation_date) is_valid = True except: print( "Card is outdated, please use card with valid validation time." ) cvc = False while cvc == False: try: cvc_num = input( "Enter CVC: \nThree numbers positioned on the back of the card." ) self.dealer_service.cb_check_cvc(cvc_num) cvc = True except: print( "The cvc is three digits, all numbers, please try again!\n" ) print("Card information has been saved for {}\n".format(name)) return card_num, validation_date, cvc def create_booking_3_of_5(self): #Header: print("DEALER/ Create booking") print("-" * 20) print("(3 of 5)") print("Please select date") print("") start_date = input("Enter start date (D/M/YYYY): ") amount_of_days = int(input("Amount of days: ")) print("") inp_car_type = " " while inp_car_type not in "ABC": try: inp_car_type = input( "Car type A = $4000 \nCar type B = $3000 \nCar type C = $2000\nSelect a car type (A, B, C): " ).upper() print("") self.admin_service.car_type_check(inp_car_type) except: print( "Available types are A, B or C. Please choose one of those types!\n" ) return start_date, amount_of_days, inp_car_type def print_end_date(self, end_date): print("End date of the rent: ", end_date) def create_booking_4_of_5(self, inp_car_type): #Header: print("DEALER/ Create booking/ Show all available cars") print("-" * 20) print("(4 of 5)\n") print("Print available cars\n") print("{:<13}{:<6}{:<7}{:<10}".format("Car lic.", "Type", "Price", "Car status")) print("-" * 36) self.__car_service.cb_show_available_cars(inp_car_type) print("") print("Extras: ") def extras(self): kasko_or_child_seat = input("1. Kasko insurance\n2. Child seat\n") more_extras = input("More extras? (y/n)") print("") return kasko_or_child_seat, more_extras def create_booking_5_of_5(self): #Header: print("DEALER/ Create booking/ Billing type") print("-" * 20) print("(5 of 5)\n") print("Please choose billing type\n") billing_type = input( "1. Credit or debit card\n2. Billing to\n3. Cash\n4. Go back\n5. Go to home page\n" ) return billing_type def credit_debit_card(self): card_name = input("Enter name of carholder: ") card_number = input("Enter card number: ") validation_time = input("Enter validation time (MM/YY)") # Setja hér tékk hvort validation_time sé "stærri" tala en dagurinn í dag # ef svo er þá kemur villa að kortið sé útrunnið return card_name, card_number, validation_time def confirm_billing(self): confirm = input("Confirm payment? (y/n)") if confirm == "y": print("Your payment has been made.") elif confirm == "n": print( "You didn't confirm the payment, you'll be transported back to choose a billing type.\n" ) return confirm def billing_to(self): comp_name = input("Enter name of company: ") amount = input("Enter amount to charge: ") due_date = input("Enter due date (D/M/YYYY): ") return comp_name, amount, due_date def cash(self, total_amount): print("Amount due: {}\n".format(total_amount)) paid_amount = input("Enter amount paid: ") return paid_amount def print_change(self, change): print("Change: {}".format(change))
def __init__(self): self.__dealer_service = Dealer_service() self.__car_service = Car_Service()
class Change_Booking_Ui: def __init__(self): self.__dealer_service = Dealer_service() self.__car_service = Car_Service() def change_booking_menu(self): change_choice = 7 while change_choice not in range(1, 4): try: print("Choose action:") print("") change_choice = int( input("1. Edit booking\n2. Cancel booking\n3. Go back\n")) self.__dealer_service.change_check( change_choice ) #hér þarf að kalla í eitthvað í service fallinu except: print("Not a valid option, please select number from 1 to 3") print("") return change_choice ############################################################################################################################ ############################################################################################################################ #EDIT BOOKING UI def find_edit_booking_name(self): name_test = False while name_test == False: try: print("Enter name of editing customer: ") first_name = input("First name: ") last_name = input("Last name: ") name = first_name.capitalize() + " " + last_name.capitalize() self.__dealer_service.edit_name(name) name_test = True except: print( "This name does not exist in the system, please try again." ) print("") return name, name_test def edit_booking_menu(self): edit_choice = 5 while edit_choice in range(1, 6): try: print("What would you like to edit?") print("") edit_choice = int( input( "1. Name\n2. License\n3. Email\n4. Phone\n5. Credit card insurance\n" )) self.__dealer_service.edit_menu_check(edit_choice) except: print("Not a valid option, please select number from 1 to 5") print("") return edit_choice def edit_name(self, name): edit_name = False while edit_name == False: try: print("Enter new customer name: ") edit_first_name = input("First name: ") edit_last_name = input("Last name: ") edit_name = edit_first_name.capitalize( ) + " " + edit_last_name.capitalize() self.__dealer_service.edit_name_check( name, edit_name) # kalla í service fall print("{} booking has been changed".format(edit_name)) print("") except: print("Whoops, something went wrong.") print("") return edit_name def edit_drivers_license(self, name): edit_drivers_license = False while edit_drivers_license == False: try: print("Enter new drivers license number: ") edit_drivers_license = input("Drivers license: ") self.__dealer_service.edit_drivers_license_check( name, edit_drivers_license) # kalla í service fall print("{} booking has been changed".format(name)) print("") except: print("Whoops, something went wrong.") print("") return edit_drivers_license def edit_email(self, name): edit_email = False while edit_email == False: try: print("Enter new email: ") edit_email = input("Email: ") self.__dealer_service.edit_email_check( name, edit_email) # kalla í service fall print("{} booking has been changed".format(name)) print("") except: print("Whoops, something went wrong.") print("") return edit_email def edit_phone_number(self, name): edit_phone_number = False while edit_phone_number == False: try: print("Enter new phone number number: ") edit_phone_number = input("Phone number: ") # edit_phone_number_check = edit_phone_number.isnumeric() self.__dealer_service.edit_phone_number( name, edit_phone_number) # kalla í service fall print("{} booking has been changed".format(name)) print("") except: print("Whoops, something went wrong.") print("") return edit_phone_number def edit_credit_card_insurance(self, name): edit_credit_card_info = False while edit_credit_card_info == False: try: print("Enter new credit card number: ") edit_credit_card_info = input("Credit card number: ") self.__dealer_service.edit_credit_card_insurance_check( name, edit_credit_card_info) # kalla í service fall print("{} booking has been changed".format(name)) print("") except: print("Whoops, something went wrong.") print("") return edit_credit_card_info ############################################################################################################################ ############################################################################################################################ #CANCEL BOOKING UI def cancel_booking(self): name = False while name == False: try: print("Enter name of cancelling customer: ") first_name = input("First name: ") last_name = input("Last name: ") name = first_name.capitalize() + " " + last_name.capitalize() self.__dealer_service.cancel_check( name) # kalla í service fall license_num = self.__car_service.cb_show_cancel_car(name) self.__car_service.cb_cancel_available(license_num) print("{} had the car {}".format(name, license_num)) print("{} booking has been cancelled".format(name)) print("") name = True except: print( "This name does not exist in the system, please try again." ) print("") return name