예제 #1
0
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())
예제 #2
0
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)
예제 #3
0
def main():
    """Test Taxi class."""
    my_taxi = Taxi("Prius 1", 100, 1.23)
    my_taxi.drive(40)
    print(my_taxi)
    my_taxi.start_fare()
    my_taxi.drive(100)
    print(my_taxi)
예제 #4
0
def main():

    new_taxi = Taxi(100)
    new_taxi.change_car_name("Prius 1")
    new_taxi.drive(40)
    print(new_taxi)
    new_taxi.start_fare()
    new_taxi.drive(100)
    print(new_taxi)
예제 #5
0
def main():
    prius_taxi = Taxi("Prius 1", 100)

    prius_taxi.drive(40)

    print(prius_taxi)

    print("Current fare : $ {:.2f}".format(prius_taxi.get_fare))

    prius_taxi.start_fare()
    prius_taxi.drive(100)

    print(prius_taxi)
    print("Current fare: $ {:.2f}".format(prius_taxi.get_fare))
예제 #6
0
def main():
    """Taxi test"""

    # Create a new taxi with name "Prius 1", 100 units of fuel and price of $1.23/km
    prius_taxi = Taxi("Prius 1", 100)

    # Drive the taxi 40km
    prius_taxi.drive(40)

    # Print the taxi's details and the current fare
    print(prius_taxi)
    print("Current fare: $ {:.2f}".format(prius_taxi.get_fare()))

    # Restart the meter (start a new fare) and then drive the car 100km
    prius_taxi.start_fare()
    prius_taxi.drive(100)

    # Print the taxi's details and the current fare
    print(prius_taxi)
    print("Current fare: $ {:.2f}".format(prius_taxi.get_fare()))
예제 #7
0
from prac08.taxi import Taxi

prius = Taxi(100, "Prius 1")
prius.drive(40)
print(f"{prius} Current fare: ${prius.get_fare():.2f}")
prius.start_fare()
prius.drive(100)
print(f"{prius} Current fare: ${prius.get_fare():.2f}")

예제 #8
0
from prac08.taxi import Taxi, SilverServiceTaxi

# Test creating a new taxi
prius_one = Taxi("Prius 1", 100)

# Test driving & __str__
prius_one.drive(40)
print(prius_one)

# Test resetting current fare
prius_one.start_fare()
prius_one.drive(100)
print(prius_one)

# Test Silver Service
silver_surfer = SilverServiceTaxi("Silver Surfer", 100, 4.85)
print(silver_surfer.price_per_km)
print(silver_surfer)

# Test with expected outputs
hummer = SilverServiceTaxi("Hummer", 200, 2)
hummer.drive(10)
print(hummer.get_fare())  # Expected $28.50 - Got $28.50

예제 #9
0
from prac08.taxi import Taxi

prius1 = Taxi("Prius 1", 100, 1.2)
prius1.drive(40)
prius1.start_fare()
prius1.drive(100)
print(prius1)