Exemplo n.º 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())
Exemplo n.º 2
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)
Exemplo n.º 3
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)
Exemplo n.º 4
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)
Exemplo n.º 5
0
def main():
    taxis = [
        Taxi(100, "Prius"),
        SilverServiceTaxi(100, "limo", 2),
        SilverServiceTaxi(200, "Hummer", 4)
    ]
    bill = 0
    current_taxi = None
    print("Let's drive!")
    print(MENU)
    choice = get_menu_choice(">>> ").lower()
    while choice != "q":
        if choice == "c":
            print("Taxis available:")
            display_taxis(taxis)
            current_taxi = int(input("Choose taxi: "))
        if choice == "d":
            try:
                distance = int(input("Drive how far? "))
                taxis[current_taxi].drive(distance)
                print(
                    f"Your {taxis[current_taxi].name} trip will cost you ${taxis[current_taxi].get_fare():.2f}"
                )
                bill += taxis[current_taxi].get_fare()
            except TypeError:
                print("Choose a taxi first")
        print(f"Bill to date: {bill:.2f}")
        print(MENU)
        choice = get_menu_choice(">>> ").lower()
    print(f"Total trip cost: ${bill:.2f}")
    print("Taxis are now: ")
    display_taxis(taxis)
Exemplo n.º 6
0
def main():
    total_bill = 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: ")
            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_bill += trip_cost
        else:
            print("Invalid option")
        print("Bill to date: ${:.2f}".format(total_bill))
        print(MENU)
        menu_choice = input(">>> ").lower()
    print("Total trip cost: ${:.2f}".format(total_bill))
    print("Taxis are now:")
    display_taxis(taxis)
def main():
    """Choose taxi to drive and print out total bills"""

    taxis = [Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4)]
    total = 0
    print("Let's drive!")
    menu_option = input("q)uit, c)hoose taxi, d)rive\n>>> ").lower()
    while menu_option != 'q':
        if menu_option == 'c':
            print("Taxis available:")
            show_taxi(taxis)
            choose_taxi = int(input("Choose taxi: "))
            chosen_taxi = taxis[choose_taxi]
        elif menu_option == 'd':
            chosen_taxi.start_fare()
            distance = float(input("Drive how far? "))
            chosen_taxi.drive(distance)
            drive_cost = chosen_taxi.get_fare()
            print("Your {} trip cost you ${:.2f}".format(chosen_taxi.name, drive_cost))
            total += drive_cost
        else:
            print("Invalid menu")
        print("Bill to date: ${:.2f}".format(total))
        menu_option = input("q)uit, c)hoose taxi, d)rive\n>>> ").lower()
    print("Total trip cost: ${:.2f}".format(total))
    print("Taxis are now: ")
    show_taxi(taxis)
Exemplo n.º 8
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()))
Exemplo n.º 9
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))
Exemplo n.º 10
0
def main():
    total_cost = 0
    taxis = [
        Taxi("Prius", 100),
        SilverServiceTaxi("Limo", 100, 2),
        SilverServiceTaxi("Hummer", 200, 4)
    ]
    current_taxi = None

    print("Lets Drive!")
    print(Menu)
    menu_choice = input("...").lower()
    while menu_choice != "":
        if menu_choice == "c":
            print("Taxis: ")
            display_taxis(taxis)
            taxi_choice = int(input("Choose your taxi: "))
            current_taxi = taxis[taxi_choice]
            print("Bill to date: ${:.2f}".format(total_cost))

        elif menu_choice == "d":
            current_taxi.start_fare()
            distance_to_drive = float(input("How far do you wish to drive? "))
            current_taxi.drive(int(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
            print("Bill to date: ${:.2f}".format(total_cost))

        elif menu_choice == "q":
            print("Total trip cost: ${:.2f}".format(total_cost))
            print("Taxis are now: ")
            display_taxis(taxis)
            break

        print(Menu)
        menu_choice = input("...").lower()

    else:
        print("Invalid Input")
def main():
    current_taxi = None
    total_bill = 0
    taxis = [
        Taxi("Prius", 100),
        SilverServiceTaxi("Limo", 100, 2),
        SilverServiceTaxi("Hummer", 200, 4)
    ]
    print("Let's drive!", menu)
    choice_of_menu = input(">>>").upper()
    while choice_of_menu != "Q":
        if choice_of_menu == 'C':
            current_taxi = taxi_choose_system(taxis)
        elif choice_of_menu == 'D':
            total_bill = drive_system(current_taxi, total_bill)
        else:
            print("Invalid menu choice")
        print("Bill to date: ${:.2f}".format(total_bill))
        print(menu)
        choice_of_menu = input(">>>").upper()
    if choice_of_menu == "Q":
        quit_system(total_bill, taxis)
Exemplo n.º 12
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}")

Exemplo n.º 13
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

Exemplo n.º 14
0
from prac08.taxi import Taxi

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