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 main(): taxi = Taxi("Prius 1", 100) taxi.drive(40) print("Current fare: {}".format(taxi.get_fare())) taxi.start_fare() taxi.drive(100) print("Current fare: {}".format(taxi.get_fare()))
def main(): prius_1 = Taxi("Prius 1", 100) prius_1.drive(40) print(prius_1) print(prius_1.get_fare())