Ejemplo n.º 1
0
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()))
Ejemplo n.º 2
0
def main():
    taxis = [
        Taxi("Prius", 100),
        SilverServiceTaxi("Limo", 100, 2),
        SilverServiceTaxi("Hummer", 200, 4)
    ]
    current_bill = 0
    chosen_taxi = taxis[0]
    print("Let's Drive!")
    print(MENU)
    menu_choice = input(">>> ").lower()
    while menu_choice != 'q':
        if menu_choice == 'c':
            chosen_taxi = get_taxi_choice(taxis)
            chosen_taxi.start_fare()

        elif menu_choice == 'd':
            drive_taxi(chosen_taxi)
            print("Your {} trip cost you ${:.2f}".format(
                chosen_taxi.name, chosen_taxi.get_fare()))
            current_bill += chosen_taxi.get_fare()

        else:
            print("Invalid Menu Choice")

        print("Bill to date: ${:.2f}".format(current_bill))
        print(MENU)
        menu_choice = input(">>> ").lower()
Ejemplo n.º 3
0
def main():
    taxis = [
        Taxi("Prius", 100),
        SilverServiceTaxi("Limo", 100, 2),
        SilverServiceTaxi("Hummer", 200, 4)
    ]
    bill_to_date = 0
    print("Let's Drive!")
    print(MENU)
    menu_choice = input(">>>")
    while menu_choice != "q":
        if menu_choice == "c":
            for i, taxi in enumerate(taxis):
                print(i, taxi)
            taxi_choice = int(input("Choose taxi:"))
            taxis[taxi_choice].start_fare()
            print("Bill to date: ${:.2f}".format(bill_to_date))
        elif menu_choice == "d":
            distance = int(input("Drive how far: "))
            taxis[taxi_choice].drive(distance)
            print("Your {} trip cost you ${:.2f}".format(
                taxis[taxi_choice].name, taxis[taxi_choice].get_fare()))
            bill_to_date += taxis[taxi_choice].get_fare()
            print("Bill to date: ${:.2f}".format(bill_to_date))
        print(MENU)
        menu_choice = input(">>>")
    print("Total trip cost: ${:.2f}".format(bill_to_date))
    print("Taxis are now: ")
    for i, taxi in enumerate(taxis):
        print(i, taxi)
Ejemplo n.º 4
0
def main():
    taxis = [
        Taxi("Prius", 100),
        SilverServiceTaxi("Limo", 100, 2),
        SilverServiceTaxi("Hummer", 200, 4)
    ]

    print("Let's drive!")
    menuChoice = input("q)uit, c)hoice, d)rive\n>>> ").lower()
    while menuChoice != 'q':
        if menuChoice == 'c':
            print("Taxis availiable")
            print_taxis(taxis)
            taxiChoice = int(input("Choose taxi: "))
            taxi = taxis[taxiChoice]
            print("Bill to date: ${:.2f}".format(taxi.get_fare()))
        elif menuChoice == 'd':
            driveDistance = int(input("Drive how far? "))
            taxi.drive(driveDistance)
            print("Your {} trip cost you ${:.2f}".format(
                taxi.name, taxi.get_fare()))
            print("Bill to date: ${:.2f}".format(taxi.get_fare()))
        else:
            print("invalid choice")
        menuChoice = input("q)uit, c)hoice, d)rive\n>>> ").lower()
    print("Taxis are now:")
    print_taxis(taxis)
Ejemplo n.º 5
0
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())
Ejemplo n.º 6
0
def main():
    # Prius =  Taxi("Prius", 100)
    # print(Prius)
    # Prius.drive(40)
    # Prius.current_fare_distance = 100
    # print(Prius)
    #
    # dodge = UnreliableCar('dodge', 100)
    # print(dodge)
    # if dodge.drive(130):
    #     print('It worked')
    # else:
    #     print("It failed")
    # print(dodge)
    #
    # taxi = SilverServiceTaxi('taxi',200,4)
    # taxi.drive(10)
    # print(taxi)
    taxis = [Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2),
             SilverServiceTaxi("Hummer", 200, 4)]
    bill = 0

    menu_choice = get_menu()

    while menu_choice != "q":
        if menu_choice == "c":
            taxi_choice = run_taxi_choice(taxis)
            print("Bill to date: ${:.2f}".format(bill))
            menu_choice = get_menu()
        elif menu_choice == "d":
            bill = run_drive(bill, taxi_choice)
            menu_choice = get_menu()
    print("Total trip cost: ${:.2f}".format(bill))
    print("Taxis are now:")
    counter = 0
    for taxi in taxis:
        print(counter, "-", taxis[counter])
        counter += 1
Ejemplo n.º 7
0
def main():
    bill = 0
    taxis = [
        Taxi("Prius", 100),
        SilverServiceTaxi("Limo", 100, 2),
        SilverServiceTaxi("Hummer", 200, 4)
    ]
    print("Let's drive!")
    current_taxi = None
    print("q)uit, c)hoose taxi, d)rive")
    menu_choice = str(input(">>> ")).lower()
    while menu_choice != "q":
        if menu_choice == "c":
            print("Taxis Avaliable:")
            for i, taxi in enumerate(taxis):
                print("{} - {}".format(i, taxi))
            taxi_choice = int(input("Choose taxi: "))
            current_taxi = taxis[taxi_choice]
            print(current_taxi)
            print("Bill to date: ${:.2f}".format(bill))

        elif menu_choice == "d":
            current_taxi.start_fare()
            get_distance = int(input("Drive how far? "))
            current_taxi.drive(get_distance)
            print("Your {} trip cost you ${:.2f}".format(
                current_taxi.name, current_taxi.get_fare()))
            bill = bill + current_taxi.get_fare()
            print("Bill to date: ${:.2f}".format(bill))
        else:
            print("Error, please enter a valid input.")
        print("q)uit, c)hoose taxi, d)rive")
        menu_choice = str(input(">>> ")).lower()
    print("Total trip cost: ${}".format(bill))
    print("Taxis are now:")
    for i, taxi in enumerate(taxis):
        print("{} - {}".format(i, taxi))
Ejemplo n.º 8
0
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()))
Ejemplo n.º 9
0
def main():
    testcar = SilverServiceTaxi("Hummer", 100, 2)
    print(testcar)
    testcar.drive(20)
    print(testcar)
    testcar.start_fare()
    print(testcar)
    testcar.drive(30)
    print(testcar)
    testcar.start_fare()
    print(testcar)
    testcar.drive(50)
    print(testcar)
    print("-" * 30)
    testcar.add_fuel(10)
    testcar.start_fare()
    print(testcar)
    testcar.drive(10)
    print("${:.2f}".format(testcar.get_fare()))
from Prac08.taxi import SilverServiceTaxi

hummer = SilverServiceTaxi("Hummer", 200, 2)
print(hummer)
hummer.start_fare()
hummer.drive(10)
print(hummer.get_fare())
Ejemplo n.º 11
0
TOP_MENU = "q)uit c)hoose taxi d)rive\n>>> "


def print_available_taxis(taxis):
    for this_taxi in range(0, len(taxis)):
        print("{} - ".format(this_taxi), taxis[this_taxi])


def print_bill(bill_value):
    print("Bill to date ${:.2f}".format(bill_value))


my_taxis = [
    Taxi("Prius", 100),
    SilverServiceTaxi("Limo", 100, 2),
    SilverServiceTaxi("Hummer", 200, 4)
]

print("Let's drive!")

total_bill = 0.00
menu_selection = ''
user_taxi = ''
while menu_selection != 'q':

    if menu_selection == 'c':
        print_available_taxis(my_taxis)
        taxi_selection = int(input("Choose taxi: "))
        user_taxi = my_taxis[taxi_selection]
        print_bill(total_bill)