def main(): t = Taxi("Prius 1", 100) t.drive(40) print(t) t.start_fare() t.drive(100) print(t)
def tests(): car = Car("Datsun", 180) car.drive(30) print("fuel =", car.fuel) print("odo =", car.odometer) car.drive(55) print("fuel =", car.fuel) print("odo = ", car.odometer) print(car) distance = int(input("Drive how far? ")) while distance > 0: travel = car.drive(distance) print("{} travelled {}".format(str(car), travel)) distance = int(input("Drive how far? ")) taxis = Taxi("Prius 1", 100) taxis.drive(25) print(taxis) print(taxis, taxis.get_fare()) taxis.start_fare() taxis.drive(40) print(taxis, taxis.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(): taxi = Taxi("Prius 1", 100, 1.23) taxi.drive(40) print(taxi) taxi.start_fare() taxi.drive(100) print(taxi)
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) # 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(): 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 main(): new_taxi = Taxi("Prius 1", 100) new_taxi.drive(40) print(new_taxi) new_taxi.start_fare() new_taxi.drive(100) print(new_taxi)
def main(): test_taxi = Taxi("Prius 1", 100) test_taxi.drive(40) print(test_taxi) test_taxi.start_fare() test_taxi.drive(100) print(test_taxi)
def main(): my_taxi = Taxi("Prius 1", 100) my_taxi.drive(40) print(my_taxi) my_taxi.start_fare() my_taxi.drive(100) print(my_taxi)
def main(): taxi_prius = Taxi("Prius", 100) taxi_prius.drive(40) print(taxi_prius) taxi_prius.start_fare() taxi_prius.drive(100) print(taxi_prius)
def main(): taxi = Taxi("Prius 1", 100) taxi.drive(40) print("{}, Fare: ${}".format(taxi, taxi.get_fare())) taxi.start_fare() taxi.drive(100) print("{}, Fare: ${}".format(taxi, taxi.get_fare()))
def main(): total_cost = 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("Taxi's available:") list_taxis(taxis) taxi_choice = int(input("Choose Taxi: ")) print("Bill to date: ${:.2f}".format( taxis[taxi_choice].get_fare())) elif user_choice == "D": current_taxi = Taxi(None, 0) current_taxi.start_fare() distance_driven = float(input("Drive how far? ")) current_taxi.drive(distance_driven) trip_cost = current_taxi.get_fare() total_cost += trip_cost print("Your {} trip cost you ${:.2f}".format( current_taxi.name, trip_cost)) else: print("Invalid Menu selection") print(MENU) user_choice = input(">>>").upper() print("Total trip cost: ${:.2f}".format(total_cost)) print("Taxi's are now:") list_taxis(taxis)
def main(): # 1 - Create a new taxi with name "Prius 1", 100 units of fuel and price of $1.23/km new_taxi = Taxi("Prius 1", 100) print(new_taxi) # 2 - Drive the taxi 40km new_taxi.drive(40) print(new_taxi) # 3 - Print the taxi's details and the current fare print(new_taxi) print("name:", new_taxi.name) print("fuel", new_taxi.fuel) print("odometer", new_taxi.odometer) print("fare distance", new_taxi.current_fare_distance) print("fare $", new_taxi.price_per_km, "per/km") print("current fare: $", new_taxi.get_fare()) # 4 - Restart the meter (start a new fare) and then drive the car 100km new_taxi.start_fare() # can only drive 60k due to fuel left new_taxi.drive(100) print(new_taxi) # 5 - Print the details and the current fare print(new_taxi) print("current fare: $", new_taxi.get_fare()) # test class variable print(new_taxi.price_per_km)
def main(): taxi_1 = Taxi("Prius 1", 100) taxi_1.drive(40) print(taxi_1) taxi_1.start_fare() taxi_1.drive(100) print(taxi_1)
def main(): my_taxi = Taxi("Prius 01", 100) my_taxi.drive(40) print(my_taxi, "${:.2f}".format(my_taxi.get_fare())) my_taxi.start_fare() my_taxi.drive(100) print(my_taxi, "${:.2f}".format(my_taxi.get_fare()))
def main(): prius = Taxi("Prius 1", 100) prius.drive(40) print("{}, (${})".format(prius.__str__(), prius.get_fare())) prius.start_fare() prius.drive(100) print("{}, (${})".format(prius.__str__(), prius.get_fare()))
def main(): prius_1 = Taxi("Prius 1", 100) prius_1.drive(40) print(prius_1) prius_1.start_fare() prius_1.drive(100) print(prius_1)
def main(): """Demo test code to show how to use car class.""" taxi = Taxi("Prius 1", 100) taxi.drive(40) print("{}\n${}".format(taxi, taxi.get_fare())) taxi.start_fare() taxi.drive(100) print("${}".format(taxi.get_fare()))
def main(): taxi = Taxi("Prius 1", 100) taxi.drive(40) print(taxi) taxi.start_fare() taxi.drive(100) print(taxi) print("Total fare is: ${:.2f}".format(taxi.get_fare()))
def main(): new_taxi = Taxi("Prius 1", 100) new_taxi.drive(40) current_fare = new_taxi.get_fare() print("{}, ${}".format(new_taxi, current_fare)) new_taxi.start_fare() current_fare = new_taxi.get_fare() print("{}, ${}".format(new_taxi, current_fare))
def main(): """Test taxi class""" my_taxi = Taxi("Prius 1", 100) my_taxi.drive(40) print("{}, Current fare: ${}".format(my_taxi, my_taxi.get_fare())) my_taxi.start_fare() my_taxi.drive(100) print("{}, Current fare: ${}".format(my_taxi, my_taxi.get_fare()))
def testing(): taxi = Taxi("Prius 1", 100) taxi.drive(40) print(taxi) taxi.start_fare() taxi.drive(100) print(taxi)
def main(): """Test Taxi class.""" new_taxi = Taxi("Prius 1", 100) new_taxi.drive(40) print(new_taxi) new_taxi.start_fare() new_taxi.drive(100) print(new_taxi)
def main(): """Test Taxi class""" taxi = Taxi("Prius 1", 100) taxi.drive(40) print(taxi) taxi.start_fare() taxi.drive(100) print(taxi)
def main(): """Test Taxi Class""" my_taxi = Taxi("Prius 1", 100) my_taxi.drive(40) print(my_taxi) my_taxi.start_fare() my_taxi.drive(100) print(my_taxi)
def main(): """Test the taxi and car classes.""" taxi = Taxi('Prius 1', 100) taxi.drive(40) print("{} Total: ${:.2f}".format(taxi, taxi.get_fare())) taxi.start_fare() taxi.drive(100) print("{} Total: ${:.2f}".format(taxi, taxi.get_fare()))
def main(): taxi = Taxi("Prius 1",100) taxi.drive(40) print(taxi) taxi.start_fare() taxi.add_fuel(60) taxi.drive(100) print(taxi)
def main(): """Test Taxi class.""" my_taxi = Taxi("Prius", 100) my_taxi.drive(40) print(my_taxi) my_taxi.start_fare() my_taxi.drive(40) print(my_taxi) print("Total cost of trip ${:.2f}".format(my_taxi.get_fare()))
def main(): prius_1 = Taxi('Prius 1', 100) prius_1.drive(40) print(prius_1) print("Current Fare: ${:.2f}".format(prius_1.get_fare())) prius_1.start_fare() prius_1.drive(100) print(prius_1) print("Current Fare: ${:.2f}".format(prius_1.get_fare()))
def main(): """Test for the Taxi class""" prius = Taxi("Prius 1", 100) prius.drive(40) print(prius) print("Fare = $", prius.get_fare()) prius.start_fare() print(prius) print("Fare = $", prius.get_fare())
def main(): """"run the test code""" my_taxi = Taxi("Prius 1", 100) my_taxi.drive(40) print_fare_details(my_taxi) my_taxi.start_fare() my_taxi.add_fuel(40) my_taxi.drive(100) print_fare_details(my_taxi)