def main(): total_cost = 0 taxis = [ Taxi("Prius 1", 100), SilverServiceTaxi("Limo 1", 100, 2), SilverServiceTaxi("Hummer 1", 200, 4) ] #Copy menu layout from assignment #Make sure everything is relating to floats not integers print("Let's drive!") print(MENU) menu_choice = input(">>> ").upper() 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_cost += trip_cost else: print("Invalid option") print("Bill to date: ${:.2f}".format(total_cost)) print(MENU) menu_choice = input(">>> ").lower() print("Total trip cost: ${:.2f}".format(total_cost)) print("Taxis are now:") display_taxis(taxis)
def main(): bill_total = 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:") taxi_display(taxis) taxi_chosen = int(input("Choose taxi:")) used_taxi = taxis[taxi_chosen] elif menu_choice == "d": used_taxi.start_fare() distance_to_drive = float(input("Drive how far? ")) used_taxi.drive(distance_to_drive) cost = used_taxi.get_fare() print("Your {} trip cost you ${:.2f}".format(used_taxi.name, cost)) bill_total += cost else: print("Invalid option") print("Bill to date: ${:.2f}".format(bill_total)) print(menu) menu_choice = input(">>> ").lower() print("Total trip cost: ${:.2f}".format(bill_total)) print("Taxis are now:") display_taxis(taxis)
def main(): #Testing Taxi test_taxi = Taxi("Prius 1", 100) test_taxi.drive(40) print(test_taxi) test_taxi.start_fare() test_taxi.drive(100) test_taxi.get_fare() print(test_taxi) #Testing Unreliable_Car test_unreliable_car = UnreliableCar("Car 1", 30, 50) test_unreliable_car.drive(10) print(test_unreliable_car) test_unreliable_car.drive(10) print(test_unreliable_car) test_unreliable_car.drive(10) print(test_unreliable_car) #Testing SilverServicesTaxis test_silvertaxi = SilverServiceTaxi("Hummer", 200, 4.0) test_silvertaxi.drive(40) print(test_silvertaxi)
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 Start_Testing(): """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) #I will need to loop 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_2 = Taxi("Prius 1", 100) print(Taxi_2) Taxi_2.drive(25) print(Taxi_2, Taxi_2.get_fare()) Taxi_2.start_fare() Taxi_2.drive(40) print(Taxi_2, Taxi_2.get_fare()) SilverTaxi = SilverServiceTaxi("Limo", 100, 2) print(SilverTaxi, SilverTaxi.get_fare()) SilverTaxi.drive(10) print(SilverTaxi, SilverTaxi.get_fare())
from taxi import Taxi from silverservicetaxi import SilverServiceTaxi print("Let's drive!") bill = 0 taxi = None taxiList = [ Taxi("Limo", 100), Taxi("Prius", 100), SilverServiceTaxi("Hummer", 200, 3.5) ] menuSelection = input("q)uit, c)hoose taxi, d)rive" "\n>>> ") while menuSelection != "q": if menuSelection == "c": print("Taxis available:") for i, taxi in enumerate(taxiList): print("{} - {}, fuel={}, odo={}, ${:.2f}/km, {}km on current fare". format(i, taxi.name, taxi.fuel, taxi.odometer, Taxi.price_per_km, taxi.total_distance)) taxiSelection = input("Choose taxi: ") taxi = taxiList[int(taxiSelection)] print("Bill to date: ${:.2f}".format(bill)) menuSelection = input("q)uit, c)hoose taxi, d)rive" "\n>>> ")
def main(): taxi = SilverServiceTaxi("Taxi 1", 100, 2) taxi.drive(18) print(taxi) print(taxi.get_fare())
from silverservicetaxi import SilverServiceTaxi taxi = SilverServiceTaxi("Fancy Taxi", 100, 2) taxi.drive(18) print(taxi) print(taxi.get_fare())
from silverservicetaxi import SilverServiceTaxi Silver_Taxi = SilverServiceTaxi("Hummer", 200, 4) print(Silver_Taxi) Silver_Taxi.drive(10) Silver_Taxi.get_fare() Test = SilverServiceTaxi("Test", 100, 2) Test.drive(18) print(Test.get_fare())
def main(): my_taxi = SilverServiceTaxi("Hummer", 200, 2) my_taxi.drive(18) print(my_taxi)
from silverservicetaxi import SilverServiceTaxi from taxi import Taxi taxis = [ Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4) ] print("Lets drive!") def main(): total_bill = 0 # initialise bill taxi_choice = 0 # default choice if none selected menu() user_input = input(">>> ").lower() while user_input != "q": if user_input == "c": taxi_choice = choose_taxi(total_bill) elif user_input == "d": total_bill = drive(taxi_choice, total_bill) menu() user_input = input(">>> ").lower() print("Total trip cost: ${}".format(total_bill)) print("Taxis are now: ") list_taxis() def drive(taxi_choice, total_bill): trip_distance = float(input("Drive how far? "))