def main(): """Main function deciphering which user input will result in which action""" taxis = [Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4)] print("Let's Drive!") print(MENU) choice = get_selection() cumulative_bill = 0 current_taxi = None while choice != 'Q': if choice == 'C': display_taxis(taxis) taxi_choice = int(input('Choose taxi: ')) print('Bill tp date: ${:.2f}'.format(cumulative_bill)) current_taxi = taxis[taxi_choice] elif choice == 'D': distance_of_drive = int(input('Drive how far? ')) current_taxi.drive(distance_of_drive) cost_of_trip = current_taxi.get_fare() print('Your {} trip cost you ${}'.format(current_taxi.name, cost_of_trip)) cumulative_bill += current_taxi.get_fare() print(MENU) choice = get_selection() print("Your final bill is {}".format(cumulative_bill)) display_taxis(taxis)
def main(): total_bill = 0 taxis = [Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4)] print("Let's drive!") print(MENU) menu_choice = input(">>> ").lower() while menu_choice != "q": if menu_choice == "c": print("Taxis available: ") display_taxis(taxis) # no error-checking taxi_choice = int(input("Choose taxi: ")) current_taxi = taxis[taxi_choice] elif menu_choice == "d": current_taxi.start_fare() distance_to_drive = float(input("Drive how far? ")) current_taxi.drive(distance_to_drive) trip_cost = current_taxi.get_fare() print("Your {} trip cost you ${:.2f}".format(current_taxi.name, trip_cost)) total_bill += trip_cost else: print("Invalid option") print("Bill to date: ${:.2f}".format(total_bill)) print(MENU) menu_choice = input(">>> ").lower() print("Total trip cost: ${:.2f}".format(total_bill)) print("Taxis are now:") display_taxis(taxis)
def main(): taxis = [Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4)] bill = 0 current_taxi = None print("Let's drive!") print(MENU) choice = input('>>> ').upper() while choice != 'Q': if choice == 'C': print("Taxis available:") for i, taxi in enumerate(taxis): # The price_per_km in example 1.20 not 1.23 print('{} - {}'.format(i,taxi)) current_taxi = int(input('Choose taxi: ')) print('Bill to date: ${:.2f}'.format(bill)) if choice == 'D': if current_taxi != None: drive_distance = int(input('Drive how far? ')) taxis[current_taxi].drive(drive_distance) # This updates self.current_fare_distance for driven distance cost_of_trip = taxis[current_taxi].get_fare() print('Your {} trip cost you ${:.2f}'.format(taxis[current_taxi].name,cost_of_trip)) bill += cost_of_trip print('Bill to date: ${:.2f}'.format(bill)) print(MENU) choice = input('>>> ').upper() print('Total trip cost: ${:.2f}'.format(bill)) print('Taxis are now:') for i, taxi in enumerate(taxis): # The price_per_km in example 1.20 not 1.23 print('{} - {}'.format(i, taxi))
def main(): print("Let's drive!") taxis = [ Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4) ] current_taxi = None taxi_bill = 0 choice = None while choice != 'q': print(MENU) choice = input(">>> ") if choice == 'c': print("Taxis available:") print_taxi_list(taxis) current_taxi = int(input("Choose taxi: ")) print("Bill to date: {:.2f}".format(taxi_bill)) if choice == 'd': taxis[current_taxi].start_fare() drive_distance = int(input("Drive how far? ")) taxis[current_taxi].drive(drive_distance) trip_fare = taxis[current_taxi].get_fare() print("Your {} trip cost you ${:.2f}".format( taxis[current_taxi].name, trip_fare)) taxi_bill += trip_fare print("Bill to date: {:.2f}".format(taxi_bill)) print("Total trip cost: ${:.2f}".format(taxi_bill)) print("Taxis are now:") print_taxi_list(taxis)
def main(): print("Let's drive!") option = menu() taxis = [Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4)] total_cost = 0 while option != "q": if option == "c": print("Taxis available:") display_taxis(taxis) taxi_choice = int(input("Choose taxi: ")) chosen_taxi = taxis[taxi_choice] elif option == "d": chosen_taxi.start_fare() get_drive_distance = float(input("Drive how far? ")) chosen_taxi.drive(get_drive_distance) current_cost = chosen_taxi.get_fare() print("Your {} trip cost you ${:.2f}".format(chosen_taxi.name, current_cost)) total_cost += current_cost else: print("Invalid input.") print("Bill to date: ${:.2f}".format(total_cost)) option = menu() print("Total trip cost: ${:.2f}".format(total_cost)) print("Taxis are now:") display_taxis(taxis)
def main(): total_bill = 0 taxis = [ Taxi('Prius', 100), SilverServiceTaxi('Limo', 100, 2), SilverServiceTaxi('Hummer', 200, 4) ] current_taxi = None print("Let's Drive!") menu_choice = input(MENU) while menu_choice != "q": if menu_choice == "c": display_taxis(taxis) taxi_choice = int(input("Choose taxi: ")) current_taxi = taxis[taxi_choice] elif menu_choice == "d": current_taxi.start_fare() distance_to_drive = float(input("Drive how far? ")) current_taxi.drive(distance_to_drive) trip_cost = current_taxi.get_fare() print("Your {} trip cost you ${}".format(current_taxi.name, trip_cost)) total_bill += trip_cost else: print("Invalid Option") print("Bill to date: ${:.2f}".format(total_bill)) menu_choice = str(input(MENU)) print("Total Trip Cost: ${:.2f}".format(total_bill)) print("Taxis are now:") display_taxis(taxis)
def main(): taxis = [ Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4) ] current_taxi = '' bill = 0.00 user_input = input('q)uit, c)hoose taxi, d)rive\n>>> ').strip().lower() while user_input != 'q': if user_input == 'c': for i, taxi in enumerate(taxis): print('{0} - {1}'.format(i, str(taxi))) current_taxi = get_taxi(taxis) elif user_input == 'd': if current_taxi == '': print('A taxi must be selected before driving!') else: taxis[current_taxi].drive( get_drive_distance(current_taxi, taxis)) bill += taxis[current_taxi].get_fare() print('Your {0} trip cost you ${1}\nBill to date: ${2}'.format( taxis[current_taxi].name, taxis[current_taxi].get_fare(), bill)) elif user_input != 'c' or 'd' or 'q': print('Enter a valid choice') user_input = input('q)uit, c)hoose taxi, d)rive\n>>> ').strip().lower()
def main(): taxis = [ Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4) ] current_taxi = None current_bill = 0 print("Let's Drive!") print(MENU) menu_choice = input(">>>>> ").lower() while menu_choice != "q": if menu_choice == "c": print("Taxis Available") choose_taxi(taxis) chosen_taxi = int(input("Choose taxi: ")) current_taxi = taxis[chosen_taxi] print("Bill to date: ${:.2f}".format(current_bill)) print(MENU) menu_choice = input(">>>>> ").lower() elif menu_choice == "d": distance = int(input("Drive how far?")) current_taxi.drive(distance) print("Your {} trip cost you ${:.2f}".format( current_taxi.name, current_taxi.get_fare())) current_bill += current_taxi.get_fare() print("Bill to date: ${:.2f}".format(current_bill)) print(MENU) menu_choice = input(">>>>> ").lower() if menu_choice == "q": choose_taxi(taxis)
def main(): taxis = [ Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4) ] current_taxi = None total_bill = 0.00 print("lets Drive!") menu_input = get_menu_choice() while menu_input != 'q': if menu_input == 'c': print_taxis(taxis) current_taxi = taxis[get_taxi_choice(len(taxis))] print(current_taxi) elif menu_input == 'd': if current_taxi is None: print("Select your vehicle!") else: current_taxi.start_fare() distance = get_distance() current_taxi.drive(distance) current_bill = current_taxi.get_fare() print("Your {} trip cost you ${:.2f}".format( current_taxi.name, current_bill)) total_bill += current_bill print("Bill to date: ${:.2f}".format(total_bill)) menu_input = get_menu_choice() print("Total trip cost: ${:.2f}".format(total_bill)) print("Taxis are now:") print_taxis(taxis)
def main(): total_bill = 0 taxis = [ Taxi("Pruis", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4) ] taxi = None print("Let's drive!") print(MENU) menu_choice = input("").upper() while menu_choice != "Q": if menu_choice == "C": display_taxis(taxis) taxi_choice = int(input("Choose taxi: ")) taxi = taxis[taxi_choice] elif menu_choice == "D": if taxi: distance_to_drive = int(input("Drive how far? ")) taxi.start_fare() taxi.drive(distance_to_drive) cost = taxi.get_fare() print("Your {} trip cost you ${:.2f}".format(taxi.name, cost)) total_bill += cost else: print("Please choose a taxi first") else: print("Invalid menu choice") print("Bill to date: ${:.2f}".format(total_bill)) print(MENU) menu_choice = input("").upper() print("Total trip cost: ${:.2f}".format(total_bill)) print("Taxis are now:") display_taxis(taxis)
def main(): taxis = [Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4)] total_bill = 0 print("Let's drive!") print("q)uit, c)hoose taxi, d)rive") menu_choice = str(input(">>> ").lower()) while menu_choice != "q": if menu_choice == "c": print("Taxis available:") taxi_information(taxis) taxi_choice = int(input("Choose taxi: ")) print("Bill to date: ${:.2f}".format(total_bill)) elif menu_choice == "d": current_taxi = taxis[taxi_choice] current_taxi.start_fare() distance_to_travel = int(input("Drive how far? ")) current_taxi.drive(distance_to_travel) current_fare = current_taxi.get_fare() total_bill += current_fare print("Your {} trip cost you ${:.2f}".format(current_taxi.name, current_fare)) print("Bill to date: ${:.2f}".format(total_bill)) print("q)uit, c)hoose taxi, d)rive") menu_choice = str(input(">>> ").lower()) print("Total trip cost: ${:.2f}".format(total_bill)) print("Taxis are now: ") taxi_information(taxis)
def main(): menu = """Q = Quit \nC = Choose Taxi\nD = Drive""" taxis = [ Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4) ] taxi = "" current_bill = 0 print(menu) choice = input(">>> ").upper() while choice != "Q": if choice == "C": taxi = choose_taxi(taxis) elif choice == "D": if taxi != "": cost = drive(taxi) current_bill += cost else: print("You need to choose a taxi before you can drive") else: print("Invalid Option") print("Your current bill is: ${:.2f}".format(current_bill)) print(menu) choice = input(">>> ").upper() print("Thank You")
def main(): """Main.""" taxis = [ Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4) ] current_bill = 0 print("Let's Drive") print(MENU) menu_selection = input(">>> ").lower() while menu_selection != QUIT: if menu_selection == CHOOSE: display_taxis(taxis) taxi_index = get_positive_number("Choose Taxi: ") current_taxi = taxis[taxi_index] current_bill += current_taxi.get_fare() elif menu_selection == DRIVE: distance = get_positive_number("Drive how far? ") current_taxi.drive(distance) current_bill += current_taxi.get_fare() print("Your {} trip cost you ${:.2f}".format( current_taxi.name, current_taxi.get_fare())) else: print("Invalid menu choice, try again.") print("Bill to date: ${:.2f}".format(current_bill)) print(MENU) menu_selection = input(">>>").lower() print("Total trip cost ${:.2f}".format(current_bill)) print("Taxis are now:") display_taxis(taxis)
def main(): taxis = [Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4)] total_bill = 0 print("Let's drive!") print(MENU) menu_choice = input(">>> ").lower() while menu_choice != "q": if menu_choice == "c": print("Taxis available:") display_taxis(taxis) taxi_choice = int(input("Choose taxi: ")) try: current_taxi = taxis[taxi_choice] except IndexError: print("Invalid Option!") elif menu_choice == "d": try: current_taxi.start_fare() drive_distance = float(input("Drive how far? ")) current_taxi.drive(drive_distance) trip_cost = current_taxi.get_fare() print("Your {} trip cost you ${:.2f}".format(current_taxi.name, trip_cost)) total_bill += trip_cost except UnboundLocalError: print("No taxi selected!") else: print("Invalid option") print("Bill to date: ${:.2f}".format(total_bill)) print(MENU) menu_choice = input(">>> ").lower() print("Total trip cost: ${:.2f}".format(total_bill)) print("Taxis are now:") display_taxis(taxis)
def main(): bill = 0 selection = "" taxi_record = [ Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4) ] print("q)uit, c)hoose taxi, d)rive") user_input = input(">>>") while user_input != "q": while user_input not in ["c", "d"]: print("q)uit, c)hoose taxi, d)rive") user_input = input(">>>") else: if user_input == "c": selection = choose_taxi(taxi_record) print("q)uit, c)hoose taxi, d)rive") user_input = input(">>>") elif user_input == "d" and selection != "": bill = drive(taxi_record, selection, bill) print("q)uit, c)hoose taxi, d)rive") user_input = input(">>>") else: print("You need to choose a taxi before you can drive") print("q)uit, c)hoose taxi, d)rive") user_input = input(">>>") print("Total trip cost: ${}".format(bill)) for item in taxi_record: print("{} - {}".format(taxi_record.index(item), item))
def main(): current_taxi = None taxis = [ Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4) ] bill_to_date = 0.00 print(MENU_STRING) choice = input(">>> ").upper() while choice != "Q": if choice == "D": if current_taxi != None: taxis[current_taxi].start_fare() distance = get_distance_to_drive() taxis[current_taxi].drive(distance) trip_cost = taxis[current_taxi].get_fare() bill_to_date += trip_cost print("Your {} trip cost you ${:.2f}".format( taxis[current_taxi].name, trip_cost)) print("Bill to date: ${:.2f}".format(bill_to_date)) else: print("You need to choose a taxi first!") elif choice == "C": current_taxi = get_chosen_taxi(taxis) print("Bill to date: ${:.2f}".format(bill_to_date)) else: print("Invalid option!") print(MENU_STRING) choice = input(">>> ").upper() print("Total trip cost: ${:,2f}".format(bill_to_date)) for index, taxi in enumerate(taxis): print("{} - {}".format(index, taxi))
def main(): print("Let's Drive!") print(MENU) total_cost = 0 taxis = [ Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4) ] choice = input(">>> ").upper() while choice != 'Q': if choice == 'C': print('Taxis available:') for i, taxi in enumerate(taxis): print("{} - {}".format(i, str(taxi))) taxi_choice = int(input("Choose Taxi: ")) selected_taxi = taxis[taxi_choice] elif choice == 'D': travel_distance = int(input("How far are you driving? ")) selected_taxi.start_fare() selected_taxi.drive(travel_distance) cost_of_trip = selected_taxi.get_fare() print("Your {} trip cost you ${:.2f}".format( selected_taxi.name, cost_of_trip)) total_cost += cost_of_trip else: print("Invalid option") print("Bill to date: ${:.2f}".format(total_cost)) print(MENU) choice = input(">>> ").upper() print("Total trip cost: ${:.2f}".format(total_cost)) print("Taxis are now:") for i, taxi in enumerate(taxis): print("{} - {}".format(i, str(taxi)))
def main(): current_taxi = " " total_bill = 0 taxis = [ Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4) ] print("Let's drive!") print(MENU) choice = input(">>> ").lower() while choice != "q": if choice == "c": print("Taxis available") display_taxis(taxis) current_taxi = get_valid_taxi("Choose taxi: ", taxis) print(taxis[current_taxi]) elif choice == "d": if current_taxi == " ": print("You need to choose a taxi before you can drive") else: # get kilometers # get fare # add fare to total_bill pass else: print("Invalid option") print(f"Bill to date: ${total_bill:.2f}") print(MENU) choice = input(">>> ").lower()
def main(): taxi = [ Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4) ] bill = 0 print("Let's drive!") menu_choice = input("q)uit, c)hoose taxi, d)rive") print(menu_choice) if menu_choice != "q": if menu_choice == "c": print("Taxi available:") print(taxi) taxi_choice = int(input("Choose taxi: ")) taxi_selected = [taxi_choice] print("Bill to date: {}".format(bill)) print() else: distance = int(input("Drive how far?")) taxi.drive(distance) print("Your {} trip cost you ${}".format(taxi.name, taxi.get_fare)) bill = bill + taxi.get_fare print("Bill to date: {}".format(bill)) print("Total trip cost: ${}".format(bill)) print("Taxis are now:") print(taxi)
def main(): taxis = [ Taxi("Prius", 100), SilverServiceTaxi("Mercedes", 75, 1.5), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4) ] bill_to_date = 0 current_taxi = None print("Let's drive!") print(MENU) menu_choice = input(PROMPT).upper() while menu_choice != 'Q': if menu_choice == 'C': current_taxi = get_taxi_choice(taxis) elif menu_choice == 'D': if current_taxi is not None: bill_to_date += drive_taxi(current_taxi) else: print("A taxi must be chosen before it can be driven") else: print("Invalid menu choice") print("Bill to date: ${:.2f}".format(bill_to_date)) print(MENU) menu_choice = input(PROMPT).upper() print("Total trip cost: ${:.2f}".format(bill_to_date)) print("Taxis are now:") display_taxis(taxis)
def main(): """Main menu driven loop""" Taxi.price_per_km = 1.20 prius = Taxi("Prius", 100) limo = SilverServiceTaxi("Limo", 100, 2) hummer = SilverServiceTaxi("Hummer", 200, 4) taxis = [prius, limo, hummer] current_taxi = '' bill_to_date = 0 print("Let's drive!") print(MENU) user_choice = get_menu_choice() while user_choice != "q": if user_choice == "c": current_taxi = choose_taxi(taxis) display_current_bill(bill_to_date) elif user_choice == "d": current_taxi.start_fare() drive_taxi(current_taxi) trip_fare = calculate_trip(current_taxi) bill_to_date += trip_fare display_current_bill(bill_to_date) print(MENU) user_choice = get_menu_choice() print("Total trip cost: {}".format(bill_to_date)) print("Taxis are now: ") display_taxis(taxis)
def main(): total_bill = 0 taxis = [ Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4) ] print("Let's drive!") print(MENU) user_choice = input(">>> ").upper() while user_choice != "Q": if user_choice == "C": print("Taxis available: ") display_taxis(taxis) taxi_choice = int(input("Choose taxi: ")) chosen_taxi = taxis[taxi_choice] elif user_choice == "D": chosen_taxi.start_fare() drive_how_much = float(input("Drive how far? ")) chosen_taxi.drive(drive_how_much) trip_cost = chosen_taxi.get_fare() print("Your {} trip cost you ${:.2f}".format( chosen_taxi.name, trip_cost)) total_bill += trip_cost else: print("Invalid menu choice") print("Bill to date: ${:.2f}".format(total_bill)) print(MENU) user_choice = input(">>> ").upper() print("Total trip cost: {:.2f}".format(total_bill)) print("Taxis are now: ") display_taxis(taxis)
def main(): print("Let's drive!") taxi_choice = -1 bill = 0 taxis = [Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4)] menu = input("q)uit, c)hoose taxi, d)rive\n>>> ").lower() while menu != "q": if menu == "c": try: taxi_choice = int(input("Taxis available\n0 - {}\n1 - {}\n2 - {}\nChoose taxi: ".format(taxis[0], taxis[1], taxis[2]))) if taxi_choice in range(0, len(taxis)): print("Bill to date: ${}".format(bill)) menu = input("q)uit, c)hoose taxi, d)rive\n>>> ").lower() else: print("Please choose a valid taxi.") except ValueError: print("Must choose a valid taxi.") elif menu == "d": if taxi_choice in range(0, len(taxis)): distance = int(input("Drive how far?: ")) taxis[taxi_choice].start_fare() taxis[taxi_choice].drive(distance) print("Your {} trip will cost you ${:,.2f}".format(taxis[taxi_choice].name, taxis[taxi_choice].get_fare())) bill += taxis[taxi_choice].get_fare() menu = input("q)uit, c)hoose taxi, d)rive\n>>> ").lower() else: print("You must select a taxi before driving.") menu = input("q)uit, c)hoose taxi, d)rive\n>>> ").lower() else: print("Invalid input.") menu = input("q)uit, c)hoose taxi, d)rive\n>>> ").lower() else: print("Total trip cost: ${:,.2f}\nTaxis are now:\n0 - {}\n1 - {}\n2 - {}".format(bill, taxis[0], taxis[1], taxis[2]))
def main(): taxis = [ Taxi("Prius", 100), Taxi("Kia", 150), SilverServiceTaxi("Hummer", 200, 4), SilverServiceTaxi("Limo", 250, 6) ] total_bill = 0 choice = input("{}\n>>>".format(MENU)).lower() current_taxi = None while choice != "q": if choice == "c": display_taxis(taxis) taxi_choice = int(input("Please choose a taxi")) current_taxi = taxis[taxi_choice] print("{} Chosen".format(taxis[taxi_choice])) elif choice == "d": if current_taxi is None: print("You need to pick a taxi first") else: current_taxi.start_fare() distance = int(input("How far would you like to drive? ")) current_taxi.drive(distance) fare_cost = current_taxi.get_fare() total_bill += fare_cost print("your trip cost you ${:.2f}".format(fare_cost)) print("Your total bill is ${:.2f}".format(total_bill)) choice = input("{}\n>>>".format(MENU)).lower()
def main(): """Initialise available taxis and constructs menu.""" current_taxi = None current_bill = 0 taxis = [Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4)] print("Let's drive!") menu_selection = '' while menu_selection != 'q': print("q)uit, c)hoose taxi, d)rive") menu_selection = input(">>> ") if menu_selection == 'c': current_taxi = choose_taxi(taxis) print("Bill to date: ${:.2f}".format(current_bill)) elif menu_selection == 'd': try: cost_of_trip = commence_trip(current_taxi) print("Your {} trip cost you ${:.2f}".format(current_taxi.name, cost_of_trip)) current_bill += cost_of_trip print("Bill to date: ${:.2f}".format(current_bill)) except AttributeError: print("Please choose a taxi first.") elif menu_selection == 'q': print("Total trip cost: ${:.2f}\nTaxis are now:".format(current_bill)) list_taxis(taxis) else: print("Please select a valid menu option:")
def main(): total_trip_cost = 0 taxis = [ Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4) ] print(MENU) menu_choice = input(">>> ").lower() while menu_choice != "q": if menu_choice == "c": print("Taxis available:") print(f"0 - {taxis[0]} \n1 - {taxis[1]} \n2 - {taxis[2]}") taxi_choice = int(input()) selected_taxi = taxis[taxi_choice] elif menu_choice == "d": travel_distance = int(input("Drive how far? ")) selected_taxi.start_fare() selected_taxi.drive(travel_distance) fare_cost = selected_taxi.get_fare() print(f"Your {selected_taxi.name} trip cost you ${fare_cost:.2f}") total_trip_cost += fare_cost else: print("Invalid entry!!") print(f"Bill to date: ${total_trip_cost:.2f}") print(MENU) menu_choice = input(">>> ").lower() print(f"Total trip cost: ${total_trip_cost:.2f}")
def main(): taxi_1 = Taxi("Prius", 100) taxi_2 = SilverServiceTaxi("Limo", 100, 2) taxi_3 = SilverServiceTaxi("Hummer", 200, 4) taxis = [taxi_1, taxi_2, taxi_3] bill = 0 run_menu(taxis, bill)
def main(): """Test Silver Service Taxi class""" my_taxi = SilverServiceTaxi("Luxury Taxi", 200, 2) print(my_taxi) my_taxi.drive(18) print(my_taxi) print("$", my_taxi.get_fare())
def main(): total_bill = 0 taxis = [ Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4) ] print("Let's drive!") print(MENU) choice = input(">>> ").upper() while choice != "Q": if choice == "C": print("Taxis available: ") taxis_list(taxis) taxi_choice = int(input("Choose taxi: ")) current_taxi = taxis[taxi_choice] elif choice == "D": current_taxi.start_fare() drive_distance = float(input("Drive how far? ")) current_taxi.drive(drive_distance) cost_of_trip = current_taxi.get_fare() print("Your {} trip cost you ${:.2f}".format( current_taxi.name, cost_of_trip)) total_bill += cost_of_trip else: print("Invalid option") print("Bill to date: ${:.2f}".format(total_bill)) print(MENU) choice = input(">>> ").upper() print("Total trip cost: ${:.2f}".format(total_bill)) print("Taxis are now:") taxis_list(taxis)
def main(): taxis = [ Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4) ] total_bill = 0 ongoing_message_header = "Taxis available:" final_message_header = "Taxis are now:" print("Let's drive!") print(MENU) menu_choice = input(">>> ").upper() while menu_choice != "Q": if menu_choice == "C": display_taxis(ongoing_message_header, taxis) user_car = taxis[int(input("Choose taxi: "))] display_current_bill(total_bill) elif menu_choice == "D": user_car.start_fare() user_car.drive(int(input("Drive how far? "))) print("Your {} trip cost you ${:.2f}".format( user_car.name, user_car.get_fare())) total_bill += user_car.get_fare() display_current_bill(total_bill) else: print("Invalid menu choice!") print(MENU) menu_choice = input(">>> ").upper() print("Total trip cost: ${:.2f}".format(total_bill)) display_taxis(final_message_header, taxis)