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(): # test Taxi class test_taxi = Taxi("Prius 1", 100) print(test_taxi) # drive 40km, print details, current fare test_taxi.drive(40) print("{} : Price: ${}".format(test_taxi, test_taxi.get_fare())) # restart meter, drive 100 test_taxi.start_fare() test_taxi.drive(100) print("{} : Price: ${}\n".format(test_taxi, test_taxi.get_fare())) # test UnreliableCar class test_unrel = UnreliableCar("UnrelCar", 100, 60) print("{} : Reliability: {}".format(test_unrel, test_unrel.reliability)) test_unrel.drive(40) print("{} : Reliability: {}\n".format(test_unrel, test_unrel.reliability)) # test SilverServiceTaxi class test_silver = SilverServiceTaxi("SilverTaxi", 100, 2) print(test_silver) test_silver.drive(10) print("Current fare: ${:.2f}".format(test_silver.get_fare()))
def main(): taxi1 = Taxi("Prius 1", 100) taxi1.drive(40) print(taxi1) taxi1.start_fare() taxi1.drive(100) print(taxi1)
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(): prius_one = Taxi("Prius 1", 100) prius_one.start_fare() prius_one.drive(40) prius_one.get_fare() print(prius_one) prius_one.start_fare() prius_one.add_fuel(100) prius_one.drive(100) print(prius_one) ute = UnreliableCar("Clunker", 100, 50) ute.drive(10) print(ute) hummer = SilverServiceTaxi("Hummer", 100, 2) hummer.drive(10) print(hummer) print(hummer.get_fare())
def main(): prius = Taxi("Prius 1", 100) prius.drive(40) print(prius) print("Current fare: ${}".format(prius.get_fare())) prius.start_fare() prius.drive(100) print(prius) print("Current fare: ${:.2f}".format(prius.get_fare())) Herbie = UnreliableCar("herbie", 100, 10.00) Herbie.drive(50) print(Herbie) Hummer = SilverServiceTaxi("Hummer", 200, 4) print(Hummer) generic = SilverServiceTaxi("Generic", 200, 2) generic.start_fare() generic.drive(10) print("Current fare: ${:.2f}".format(generic.get_fare()))
def main(): my_taxi = Taxi("Prius 1", 100) my_taxi.drive(40) print(my_taxi) my_taxi.drive(100) print(my_taxi)
from Prac08.taxi import Taxi new_taxi = Taxi("Prius 1", 100) print(new_taxi) new_taxi.start_fare() new_taxi.drive(40) print(new_taxi) print(new_taxi.get_fare()) new_taxi.start_fare() new_taxi.drive(100) print(new_taxi) print(new_taxi.get_fare())
""" test taxi CP1404 Practical """ from Prac08.taxi import Taxi prius = Taxi("Prius 1", 100) prius.drive(40) prius.start_fare() prius.drive(100) print(prius.get_fare())
from Prac08.taxi import Taxi newTaxi = Taxi("Prius 1", 100) newTaxi.drive(40) print(newTaxi) print("Your fare: ${:.2f}".format(newTaxi.get_fare())) newTaxi.start_fare() newTaxi.drive(100) print(newTaxi) print("Your fare: ${:.2f}".format(newTaxi.get_fare()))