def main(): taxis = [Taxi("Prius", 100, 1.2), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4)] print("Let's drive!") current_taxi = taxis[0] total_cost = 0 menu_choice = input("q)uit, c)hoose taxi, d)rive").lower() while menu_choice != "q": if menu_choice == "c": print("Taxis available:") taxi_number = 0 for taxi in taxis: print("{} - {}".format(taxi_number, taxi)) taxi_number += 1 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_cost += trip_cost print("Bill to date: ${:.2f}".format(total_cost)) menu_choice = input("q)uit, c)hoose taxi, d)rive").lower() print("Total trip cost: ${:.2f}\nTaxis are now:".format(total_cost)) taxi_number = 0 for taxi in taxis: print("{} - {}".format(taxi_number, taxi)) taxi_number += 1
def main(): current_taxi = None total_cost = 0 taxis = [ Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4) ] print('Let\'s drive!') while True: choice = str(input('q)uit, c)hoose taxi, d)rive\n>>> ')).lower() valid_choice = "qcd" if choice not in valid_choice: print("Invalid choice.\n") if choice == 'c': current_taxi = choose_taxi(taxis) if choice == 'd': drive(taxis, current_taxi, total_cost) if choice == 'q': print("Total trip cost: ${:.2f}".format(total_cost)) print("Taxis are now:") list_taxi(taxis) print("Bill to date: ${:.2f}\n".format(total_cost))
def main(): """Taxi Simulator, the user chooses a taxi to drive and how far they want to drive. The fare for each trip is added to the bill until the user quits the program.""" taxis = [ Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4) ] current_taxi = None bill = 0 print("Let's drive!") print(MENU) menu_input = input(">>> ").lower() while menu_input != 'q': if menu_input == 'c': current_taxi = choose_taxi(taxis) elif menu_input == 'd': if current_taxi is None: print("No taxi selected, choose a taxi first!") else: drive_taxi(current_taxi) else: print("Invalid input, try again") bill = calculate_total_bill(taxis) print("Bill to date: ${:.2f}".format(bill)) print(MENU) menu_input = input(">>> ").lower() bill = calculate_total_bill(taxis) print("Total trip cost: ${:.2f}".format(bill)) display_taxis(taxis)
def main(): """Test the SilverServiceTaxi class.""" hummer = SilverServiceTaxi('Hummer', 200, 2) print(hummer) hummer.drive(18) print("Your current fare is ${:.2f}".format(hummer.get_fare())) print(hummer)
def main(): # total bill total_cost = 0 # Generate three cars cars = [Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4)] # Current operate car cur_car = None print("Let's drive!") user_select = get_user_select() while user_select != "q": if user_select == "c": # Choose a car cur_car = get_choose_car(cars) elif user_select == "d": # Drive a car if cur_car is None: print("You should choose a taxi first!") else: cur_car.start_fare() distance_to_drive = float(input("Drive how far? ")) cur_car.drive(distance_to_drive) trip_cost = cur_car.get_fare() print("Your {} trip cost you ${:.2f}".format(cur_car.name, trip_cost)) total_cost += trip_cost print("Bill to date: ${:.2f}".format(total_cost)) user_select = get_user_select() print("Total trip cost: ${:.2f}".format(total_cost)) print("Taxis are now:") show_cars(cars)
def main(): global taxis global Total Total = 0 taxis = [Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4)] print('Let\'s drive! ') menu()
def main(): """Test silver service taxi program""" """Test SilverServiceTaxi""" my_silver_taxi = SilverServiceTaxi("Porsche 911", 200, 2) my_silver_taxi.drive(18) print("The fare for this trip is ${:.2f}".format( my_silver_taxi.get_fare())) print(my_silver_taxi)
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) 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(): print("Let's Drive") taxis = [ TaxiModified("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4) ] bill_to_date = 0 my_taxi = None main_menu(taxis, bill_to_date, my_taxi)
def main(): """Test SilverServiceTaxi.""" taxi = SilverServiceTaxi("Test Fancy Taxi", 100, 2) taxi.drive(18) print(taxi) print(taxi.get_fare())
def main(): """...""" prius = Taxi("prius", 100) limo = SilverServiceTaxi("Limo", 100, 2) hummer = SilverServiceTaxi("Hummer", 200, 4) print(prius, "\n", limo, "\n", hummer) print(MENU) current_taxi = None taxis = [ Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4) ] bill_to_date = 0 while MENU != "Q": if MENU == "C": print("Taxis available:") for number, current_taxi in enumerate(taxis): print(f"{number} - {current_taxi}") choose_taxi = int(input("Choose current_taxi: ")) current_taxi = taxis[choose_taxi] print(current_taxi) print(f"Bill to date: ${bill_to_date:.2f}") elif MENU == "D": drive_taxi = int(input("Drive how far? ")) current_taxi.drive(drive_taxi) print( f"Your {current_taxi.name} trip cost you ${current_taxi.get_fare()}" ) bill_to_date += current_taxi.get_fare() else: print("Invalid input error message") print(MENU)
def main(): taxis = [ Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4) ] taxi_choice = "" bill_total = 0.0 print("Let's drive!") print("q)uit, c)hoose taxi, d)rive") menu_choice = input(">>> ").lower() while menu_choice != "q": if menu_choice == "c": print("Taxis available:") for index, taxi in enumerate(taxis): print("{} - {}".format(index, taxi)) taxi_choice = int(input("Choose taxi: ")) if 0 <= taxi_choice > len(taxis) - 1: print("Invalid taxi choice") taxi_choice = "" else: current_taxi = taxis[taxi_choice] elif menu_choice == "d": if taxi_choice == "": print("You need to choose a taxi before you can drive") else: current_taxi.start_fare() driving_distance = int(input("Drive how far? ")) current_taxi.drive(driving_distance) current_fare = current_taxi.get_fare() bill_total += current_fare print("Your {} trip cost you ${:.2f}".format( current_taxi.name, current_fare)) else: print("Invalid option") print("Bill to date: ${:.2f}".format(bill_total)) print("q)uit, c)hoose taxi, d)rive") menu_choice = input(">>> ").lower() print("Total trip cost ${:.2f}".format(bill_total)) print("Taxis are now:") for index, taxi in enumerate(taxis): print("{} - {}".format(index, taxi))
def main(): """ A taxi simulator program that uses your Taxi and SilverServiceTaxi classes. Each time, until they quit: The user should be presented with a list of available taxis and get to choose one. Then they should say how far they want to drive. At the end of each trip, show them the price and add it to their bill. """ 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(): total = 0 menu_choices = "q)uit, c)hoose, d)rive" taxis = [ Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4) ] current_taxi = None print("Let's Drive") print(menu_choices) menu_choice = input(">>> ").lower() while menu_choice != "q": if menu_choice == "c": choose_taxi(taxis) taxi_choice = int(input("Choose taxi: ")) try: current_taxi = taxis[taxi_choice] except IndexError: print("Invalid taxi choice") elif menu_choice == "d": if current_taxi: current_taxi.start_fare() drive_distance = float(input("Drive how far? ")) current_taxi.drive(drive_distance) cost = current_taxi.get_fare() print(f"Your {current_taxi.name} trip cost you ${cost:.2f}") total += cost else: print("You need to choose a taxi before you can drive") else: print("Invalid Option") print(f"Bill to date : ${total:.2f}") print(menu_choices) menu_choice = input(">>> ").lower() print("Taxis are now: ") choose_taxi(taxis)
def main(): """Simulate taxi service using Taxi and SilverServiceTaxi Classes.""" taxis = [ Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4) ] current_taxi = None bill_to_date = 0 print("Let's drive!") print(MENU) choice = input(">>> ") while choice.lower() != 'q': if choice.lower() == 'c': print("Taxis available:") taxis_available(taxis) current_taxi = get_valid_taxi(taxis) elif choice.lower() == 'd': if current_taxi: # Check that there is a currently selected taxi if current_taxi.fuel == 0: # Check if the selected taxi is out of fuel print( "Sorry, that taxi is all out of fuel. Please choose another Taxi first." ) else: distance = get_valid_distance() current_taxi.start_fare() current_taxi.drive(distance) trip_fare = current_taxi.get_fare() print("Your {} trip cost you ${:.2f}".format( current_taxi.name, trip_fare)) bill_to_date += trip_fare else: print("No taxi selected, please choose a taxi first") else: print("Invalid choice") print("Bill to date: ${:.2f}".format(bill_to_date)) print(MENU) choice = input(">>> ") print("Taxis are now:") taxis_available(taxis)
def run_tests(): bus = Car("Datsun", 180) bus.drive(30) print("fuel =", bus.fuel) print("odo =", bus.odometer) bus.drive(55) print("fuel =", bus.fuel) print("odo = ", bus.odometer) print(bus) # drive bus (input/loop is oblivious to fuel) distance = int(input("Drive how far? ")) while distance > 0: travelled = bus.drive(distance) print("{} travelled {}".format(str(bus), travelled)) distance = int(input("Drive how far? ")) t = Taxi("Prius 1", 100) print(t) t.drive(25) print(t, t.get_fare()) t.start_fare() t.drive(40) print(t, t.get_fare()) sst = SilverServiceTaxi("Limo", 100, 2) print(sst, sst.get_fare()) sst.drive(10) print(sst, sst.get_fare())
def run_tests(): """Run tests to show workings of Car and Taxi classes.""" bus = Car("Datsun", 180) bus.drive(30) print("fuel =", bus.fuel) print("odo =", bus.odometer) bus.drive(55) print("fuel =", bus.fuel) print("odo = ", bus.odometer) print(bus) distance = int(input("Drive how far? ")) while distance > 0: travelled = bus.drive(distance) print("{} travelled {}".format(str(bus), travelled)) distance = int(input("Drive how far? ")) t = Taxi("Prius 1", 100) print(t) t.drive(25) print(t, t.get_fare()) t.start_fare() t.drive(40) print(t, t.get_fare()) sst = SilverServiceTaxi("Limo", 100, 2) print(sst, sst.get_fare()) sst.drive(10) print(sst, sst.get_fare())
def run_tests(): bus = Car("Datsun", 180) bus.drive(30) print("fuel =", bus.fuel) print("odo =", bus.odometer) bus.drive(55) print("fuel =", bus.fuel) print("odo = ", bus.odometer) print(bus) distance = int(input("Drive how far? ")) while distance > 0: travelled = bus.drive(distance) print("{} travelled {}".format(str(bus), travelled)) distance = int(input("Drive how far? ")) taxi = Taxi("Prius 1", 100) print(taxi) taxi.drive(25) print(taxi, taxi.get_fare()) taxi.start_fare() taxi.drive(40) print(taxi, taxi.get_fare()) silver_service_taxi = SilverServiceTaxi("Limo", 100, 2) print(silver_service_taxi, silver_service_taxi.get_fare()) silver_service_taxi.drive(10) print(silver_service_taxi, silver_service_taxi.get_fare())
def main(): """Test cases for SilverServiceTaxi class""" hummer = SilverServiceTaxi("Hummer", 200, 4) print(hummer) limo = SilverServiceTaxi("Limo", 200, 2) limo.drive(18) print(limo) print("${:.2f}".format(limo.get_fare()))
def main(): print("Let's drive!") taxis = [ Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4) ] current_taxi = None bill = 0.0 command = '' while command.lower() != 'q': print(MENU) command = input(">>> ").lower()[0] if command == 'd': if current_taxi is None: print("Please select a taxi first.") else: distance = input("Distance: ") while not distance.isdigit(): distance = input("Please enter a valid distance: ") print("Distance driven:", current_taxi.drive(int(distance))) print(f"Your {current_taxi.name} trip cost you:", current_taxi.get_fare()) bill += current_taxi.get_fare() print("Bill to date:", bill) elif command == 'c': print("Taxis available:\n" + list_taxis(taxis)) done = False while not done: index = input("Choose taxi: ") if index.isdigit(): if int(index) > 0 and int(index) <= len(taxis): done = True current_taxi = taxis[int(index) - 1] print(str(current_taxi)) current_taxi.start_fare() print(f"Total trip cost: {bill:.2f}" + '\nTaxis are now:\n' + list_taxis(taxis))
def main(): """Each time, until they quit: The user should be presented with a list of available taxis and get to choose one. Then they should say how far they want to drive. At the end of each trip, show them the price and add it to their bill.""" total_bill = 0 current_taxi = None taxis = [Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4)] print("Let's drive!") print(MENU) option = input(">>>").lower() while option != 'q': if option == 'c': print('Taxis available:') display_taxis(taxis) current_taxi_num = int(input("Choose taxi: ")) while current_taxi_num not in range(len(taxis)): current_taxi_num = int(input("Choose taxi: ")) current_taxi = taxis[current_taxi_num] print("Bill to date: ${:.2f}".format(total_bill)) print(MENU) option = input(">>>").lower() elif option == 'd': current_taxi.start_fare() distance = float(input("Drive how far? ")) current_taxi.drive(distance) print("Your {} trip cost you ${:.2f}".format(current_taxi.name, current_taxi.get_fare())) total_bill += current_taxi.get_fare() print("Bill to date: ${:.2f}".format(total_bill)) print(MENU) option = input(">>>").lower() else: print("Invalid option") print(MENU) option = input(">>>").lower() print("Total trip cost: ${:.2f}".format(total_bill)) print("Taxis are now:") display_taxis(taxis)
def main(): current_taxi = None bill = 0 taxis = [Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4)] print("Let's drive!") print(MENU) menu_choice = input(PROMPT).lower() while menu_choice != 'q': if menu_choice == 'c': current_taxi = choose_taxi(taxis) elif menu_choice == 'd': if current_taxi is None: print("You haven't chosen a taxi to drive yet!") else: bill += drive_taxi(current_taxi) else: print("Invalid Menu Choice") print("Bill to date: ${:.2f}".format(bill)) print(MENU) menu_choice = input(PROMPT).lower() print("Total trip cost: ${:.2f}".format(bill)) print("Taxis are now:") print_taxis(taxis)
def main(): taxis = [Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4)] print("Let's drive!") print(MENU) total_bill = 0 user_choice = input(">>> ") while user_choice.lower() != "q": if user_choice.lower() == "c": display_available_taxis(taxis) taxi_choice = int(input("Choose taxi: ")) current_taxi = taxis[taxi_choice] print("Bill to date: ${:.2f}".format(total_bill)) elif user_choice.lower() == "d": taxi_cost = drive_taxi(current_taxi) total_bill += taxi_cost print("Bill to date: ${:.2f}".format(total_bill)) else: print("Invalid menu option") print(MENU) user_choice = input(">>> ").lower() print("Total trip cost: ${:.2f}".format(total_bill)) print("Taxis are now:") display_available_taxis(taxis)
def main(): bill = 0 current_taxi = None taxis = [ Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4) ] print("Let's drive!") menu = "q)uit, c)hoose taxi, d)rive" print(menu) choice = input(">>> ").lower() while choice != "q": if choice == "c": print("Taxis available: ") for i, taxi in enumerate(taxis): print("{} - {}".format(i, taxi)) taxi_choice = int(input("Choose taxi:")) current_taxi = taxis[taxi_choice] elif choice == "d": current_taxi.start_fare() distance = int(input("Drive how far? ")) current_taxi.drive(distance) cost = current_taxi.get_fare() print("Your {} trip cost you ${:.2f}".format( current_taxi.name, cost)) bill += cost print("Bill to date: ${:.2f}".format(bill)) print(menu) choice = input(">>> ").lower() print("Total trip cost: ${:.2f}".format(bill)) print("Taxis are now:") for i, taxi in enumerate(taxis): print("{} - {}".format(i, taxi))
def main(): taxi = SilverServiceTaxi('Fancy Taxi', 100, 2) taxi.drive(18) print(taxi.get_fare())
def main(): silver_service_taxi = SilverServiceTaxi("Mclaren 720s", 200, 1.23, 2) print(silver_service_taxi) print(silver_service_taxi.get_fare(18))
def main(): Hummer = SilverServiceTaxi("Hummer", 200, 4) print(Hummer.__str__())
from silver_service_taxi import SilverServiceTaxi hummer_taxi = SilverServiceTaxi("hummer", 200, 4) print(hummer_taxi) limo_taxi = SilverServiceTaxi("limo", 100, 2) limo_taxi.drive(18) print(limo_taxi) print(limo_taxi.get_fare()) test_taxi = SilverServiceTaxi("limo", 100, 2) print(test_taxi.get_fare())
"""Test program for SilverServiceTaxi class.""" from silver_service_taxi import SilverServiceTaxi hummer = SilverServiceTaxi('Hummer', 200, 4) print(hummer) silver_service_taxi_1 = SilverServiceTaxi('Silver Service Taxi', 18, 2) silver_service_taxi_1.drive(18) print(silver_service_taxi_1) fare = silver_service_taxi_1.get_fare() print(f"{silver_service_taxi_1.name} current fare price is ${fare:.2f}")
def main(): """price per km time 10(fanciness) = 12.30 per km, times the distance drove which is also 10""" sstaxi = SilverServiceTaxi("Silver Service Taxi", 100, 10) sstaxi.drive(10) print(sstaxi) print(sstaxi.get_fare())