def main():
    total_cost = 0
    taxis = [
        Taxi("Prius", 100),
        SilverServiceTaxi("Limo", 100, 2),
        SilverServiceTaxi("Hummer", 200, 4)
    ]
    print("Let's drive!")
    print(MENU)
    user_choice = input(">>>").upper()

    while user_choice != "Q":
        if user_choice == "C":
            print("Taxi's available:")
            list_taxis(taxis)
            taxi_choice = int(input("Choose Taxi: "))
            print("Bill to date: ${:.2f}".format(
                taxis[taxi_choice].get_fare()))
        elif user_choice == "D":
            current_taxi = Taxi(None, 0)
            current_taxi.start_fare()
            distance_driven = float(input("Drive how far? "))
            current_taxi.drive(distance_driven)
            trip_cost = current_taxi.get_fare()
            total_cost += trip_cost
            print("Your {} trip cost you ${:.2f}".format(
                current_taxi.name, trip_cost))
        else:
            print("Invalid Menu selection")
        print(MENU)
        user_choice = input(">>>").upper()

    print("Total trip cost: ${:.2f}".format(total_cost))
    print("Taxi's are now:")
    list_taxis(taxis)
Ejemplo n.º 2
0
def main():
    taxis = [
        Taxi("Prius", 100),
        Taxi("Kia", 150),
        SilverServiceTaxi("Hummer", 200, 4),
        SilverServiceTaxi("Limo", 250, 6)
    ]
    total_bill = 0
    choice = input("{}\n>>>".format(MENU)).lower()
    current_taxi = None
    while choice != "q":
        if choice == "c":
            display_taxis(taxis)
            taxi_choice = int(input("Please choose a taxi"))
            current_taxi = taxis[taxi_choice]
            print("{} Chosen".format(taxis[taxi_choice]))
        elif choice == "d":
            if current_taxi is None:
                print("You need to pick a taxi first")
            else:
                current_taxi.start_fare()
                distance = int(input("How far would you like to drive? "))
                current_taxi.drive(distance)
                fare_cost = current_taxi.get_fare()
                total_bill += fare_cost
                print("your trip cost you ${:.2f}".format(fare_cost))
        print("Your total bill is ${:.2f}".format(total_bill))
        choice = input("{}\n>>>".format(MENU)).lower()
Ejemplo n.º 3
0
def run_tests():
    """Run tests to show workings of Car and Taxi classes."""
    test_bus = Car("Test Bus", 200)
    test_bus.drive(30)
    print("fuel =", test_bus.fuel)
    print("odo =", test_bus.odometer)
    test_bus.drive(60)
    print("fuel =", test_bus.fuel)
    print("odo = ", test_bus.odometer)
    print(test_bus)

    # Drive a bus
    print("Enter driving distance:")
    distance = int(input(">> "))
    while distance > 0:
        distance_travelled = test_bus.drive(distance)
        print("{} has travelled {} km.".format(test_bus, distance_travelled))
        print("Enter driving distance (km):")
        distance = int(input(">> "))

    test_taxi = Taxi("Test Taxi", 100)
    print(test_taxi)
    test_taxi.drive(30)
    print(test_taxi, test_taxi.get_fare())
    test_taxi.start_fare()
    test_taxi.drive(60)
    print(test_taxi, test_taxi.get_fare())

    fancy_taxi = Taxi("Test Fancy Taxi", 100, 2)
    print(fancy_taxi)
    fancy_taxi.drive(30)
    print(fancy_taxi, fancy_taxi.get_fare())
def run_tests():
    """Test functions."""
    print(get_positive_integer())
    print(get_positive_float())
    taxis = [
        Taxi("Van", 100),
        Taxi("Ute", 100),
        SilverServiceTaxi("Limo", 100, 2)
    ]
    display_taxis(taxis)
    print(get_taxi_number(taxis))
Ejemplo n.º 5
0
def main():
    total_bill = 0
    taxis = [
        Taxi("Prius", 100),
        SilverServiceTaxi("Limo", 100, 2),
        SilverServiceTaxi("Hummer", 200, 4)
    ]
    print("Let's drive!")
    print(MENU)
    choice = input(">>> ").upper()
    while choice != "Q":
        if choice == "C":
            print("Taxis available: ")
            taxis_list(taxis)
            taxi_choice = int(input("Choose taxi: "))
            current_taxi = taxis[taxi_choice]
        elif choice == "D":
            current_taxi.start_fare()
            drive_distance = float(input("Drive how far? "))
            current_taxi.drive(drive_distance)
            cost_of_trip = current_taxi.get_fare()
            print("Your {} trip cost you ${:.2f}".format(
                current_taxi.name, cost_of_trip))
            total_bill += cost_of_trip
        else:
            print("Invalid option")
        print("Bill to date: ${:.2f}".format(total_bill))
        print(MENU)
        choice = input(">>> ").upper()
    print("Total trip cost: ${:.2f}".format(total_bill))
    print("Taxis are now:")
    taxis_list(taxis)
Ejemplo n.º 6
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)
Ejemplo n.º 7
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())
Ejemplo n.º 8
0
def main():
    taxi_1 = Taxi("Prius 1", 100)
    taxi_1.drive(40)
    print(taxi_1)
    taxi_1.start_fare()
    taxi_1.drive(100)
    print(taxi_1)
def main():
    print("Let's drive!")
    taxi_choice = -1
    bill = 0
    taxis = [Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4)]
    menu = input("q)uit, c)hoose taxi, d)rive\n>>> ").lower()
    while menu != "q":
        if menu == "c":
            try:
                taxi_choice = int(input("Taxis available\n0 - {}\n1 - {}\n2 - {}\nChoose taxi: ".format(taxis[0], taxis[1], taxis[2])))
                if taxi_choice in range(0, len(taxis)):
                    print("Bill to date: ${}".format(bill))
                    menu = input("q)uit, c)hoose taxi, d)rive\n>>> ").lower()
                else:
                    print("Please choose a valid taxi.")
            except ValueError:
                print("Must choose a valid taxi.")
        elif menu == "d":
            if taxi_choice in range(0, len(taxis)):
                distance = int(input("Drive how far?: "))
                taxis[taxi_choice].start_fare()
                taxis[taxi_choice].drive(distance)
                print("Your {} trip will cost you ${:,.2f}".format(taxis[taxi_choice].name, taxis[taxi_choice].get_fare()))
                bill += taxis[taxi_choice].get_fare()
                menu = input("q)uit, c)hoose taxi, d)rive\n>>> ").lower()
            else:
                print("You must select a taxi before driving.")
                menu = input("q)uit, c)hoose taxi, d)rive\n>>> ").lower()
        else:
            print("Invalid input.")
            menu = input("q)uit, c)hoose taxi, d)rive\n>>> ").lower()
    else:
        print("Total trip cost: ${:,.2f}\nTaxis are now:\n0 - {}\n1 - {}\n2 - {}".format(bill, taxis[0], taxis[1], taxis[2]))
Ejemplo n.º 10
0
def main():
    print("Let's drive!")
    taxis = [
        Taxi("Prius", 100),
        SilverServiceTaxi("Limo", 100, 2),
        SilverServiceTaxi("Hummer", 200, 4)
    ]
    current_taxi = None
    taxi_bill = 0
    choice = None
    while choice != 'q':
        print(MENU)
        choice = input(">>> ")
        if choice == 'c':
            print("Taxis available:")
            print_taxi_list(taxis)
            current_taxi = int(input("Choose taxi: "))
            print("Bill to date: {:.2f}".format(taxi_bill))
        if choice == 'd':
            taxis[current_taxi].start_fare()
            drive_distance = int(input("Drive how far? "))
            taxis[current_taxi].drive(drive_distance)
            trip_fare = taxis[current_taxi].get_fare()
            print("Your {} trip cost you ${:.2f}".format(
                taxis[current_taxi].name, trip_fare))
            taxi_bill += trip_fare
            print("Bill to date: {:.2f}".format(taxi_bill))
    print("Total trip cost: ${:.2f}".format(taxi_bill))
    print("Taxis are now:")
    print_taxi_list(taxis)
Ejemplo n.º 11
0
def main():
    print("Let's Drive!")
    print(MENU)
    total_cost = 0
    taxis = [
        Taxi("Prius", 100),
        SilverServiceTaxi("Limo", 100, 2),
        SilverServiceTaxi("Hummer", 200, 4)
    ]
    choice = input(">>> ").upper()
    while choice != 'Q':
        if choice == 'C':
            print('Taxis available:')
            for i, taxi in enumerate(taxis):
                print("{} - {}".format(i, str(taxi)))
            taxi_choice = int(input("Choose Taxi: "))
            selected_taxi = taxis[taxi_choice]
        elif choice == 'D':
            travel_distance = int(input("How far are you driving? "))
            selected_taxi.start_fare()
            selected_taxi.drive(travel_distance)
            cost_of_trip = selected_taxi.get_fare()
            print("Your {} trip cost you ${:.2f}".format(
                selected_taxi.name, cost_of_trip))
            total_cost += cost_of_trip
        else:
            print("Invalid option")
            print("Bill to date: ${:.2f}".format(total_cost))
        print(MENU)
        choice = input(">>> ").upper()

    print("Total trip cost: ${:.2f}".format(total_cost))
    print("Taxis are now:")
    for i, taxi in enumerate(taxis):
        print("{} - {}".format(i, str(taxi)))
Ejemplo n.º 12
0
def main():
    bill = 0
    selection = ""
    taxi_record = [
        Taxi("Prius", 100),
        SilverServiceTaxi("Limo", 100, 2),
        SilverServiceTaxi("Hummer", 200, 4)
    ]
    print("q)uit, c)hoose taxi, d)rive")
    user_input = input(">>>")
    while user_input != "q":
        while user_input not in ["c", "d"]:
            print("q)uit, c)hoose taxi, d)rive")
            user_input = input(">>>")
        else:
            if user_input == "c":
                selection = choose_taxi(taxi_record)
                print("q)uit, c)hoose taxi, d)rive")
                user_input = input(">>>")
            elif user_input == "d" and selection != "":
                bill = drive(taxi_record, selection, bill)
                print("q)uit, c)hoose taxi, d)rive")
                user_input = input(">>>")
            else:
                print("You need to choose a taxi before you can drive")
                print("q)uit, c)hoose taxi, d)rive")
                user_input = input(">>>")
    print("Total trip cost: ${}".format(bill))
    for item in taxi_record:
        print("{} - {}".format(taxi_record.index(item), item))
Ejemplo n.º 13
0
def main():

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

    print(MENU)
    menu_choice = input(">>> ").lower()
    while menu_choice != "q":
        if menu_choice == "c":
            print("Taxis available:")
            print(f"0 - {taxis[0]} \n1 - {taxis[1]} \n2 - {taxis[2]}")
            taxi_choice = int(input())
            selected_taxi = taxis[taxi_choice]
        elif menu_choice == "d":
            travel_distance = int(input("Drive how far? "))
            selected_taxi.start_fare()
            selected_taxi.drive(travel_distance)
            fare_cost = selected_taxi.get_fare()
            print(f"Your {selected_taxi.name} trip cost you ${fare_cost:.2f}")
            total_trip_cost += fare_cost
        else:
            print("Invalid entry!!")
        print(f"Bill to date: ${total_trip_cost:.2f}")
        print(MENU)
        menu_choice = input(">>> ").lower()
    print(f"Total trip cost: ${total_trip_cost:.2f}")
Ejemplo n.º 14
0
def main():
    taxi = Taxi("Prius 1", 100, 1.23)
    taxi.drive(40)
    print(taxi)
    taxi.start_fare()
    taxi.drive(100)
    print(taxi)
Ejemplo n.º 15
0
def main():
    total_bill = 0
    taxis = [
        Taxi("Prius", 100),
        SilverServiceTaxi("Limo", 100, 2),
        SilverServiceTaxi("Hummer", 200, 4)
    ]
    print("Let's drive!")
    print(MENU)
    user_choice = input(">>> ").upper()
    while user_choice != "Q":
        if user_choice == "C":
            print("Taxis available: ")
            display_taxis(taxis)
            taxi_choice = int(input("Choose taxi: "))
            chosen_taxi = taxis[taxi_choice]
        elif user_choice == "D":
            chosen_taxi.start_fare()
            drive_how_much = float(input("Drive how far? "))
            chosen_taxi.drive(drive_how_much)
            trip_cost = chosen_taxi.get_fare()
            print("Your {} trip cost you ${:.2f}".format(
                chosen_taxi.name, trip_cost))
            total_bill += trip_cost
        else:
            print("Invalid menu choice")
        print("Bill to date: ${:.2f}".format(total_bill))
        print(MENU)
        user_choice = input(">>> ").upper()
    print("Total trip cost: {:.2f}".format(total_bill))
    print("Taxis are now: ")
    display_taxis(taxis)
Ejemplo n.º 16
0
def main():
    taxi_prius = Taxi("Prius", 100)
    taxi_prius.drive(40)
    print(taxi_prius)
    taxi_prius.start_fare()
    taxi_prius.drive(100)
    print(taxi_prius)
Ejemplo n.º 17
0
def main():
    """Main menu driven loop"""
    Taxi.price_per_km = 1.20
    prius = Taxi("Prius", 100)
    limo = SilverServiceTaxi("Limo", 100, 2)
    hummer = SilverServiceTaxi("Hummer", 200, 4)
    taxis = [prius, limo, hummer]

    current_taxi = ''
    bill_to_date = 0

    print("Let's drive!")
    print(MENU)
    user_choice = get_menu_choice()
    while user_choice != "q":

        if user_choice == "c":
            current_taxi = choose_taxi(taxis)
            display_current_bill(bill_to_date)

        elif user_choice == "d":
            current_taxi.start_fare()
            drive_taxi(current_taxi)
            trip_fare = calculate_trip(current_taxi)
            bill_to_date += trip_fare
            display_current_bill(bill_to_date)

        print(MENU)
        user_choice = get_menu_choice()

    print("Total trip cost: {}".format(bill_to_date))
    print("Taxis are now: ")
    display_taxis(taxis)
Ejemplo n.º 18
0
def main():
    # 1 - Create a new taxi with name "Prius 1", 100 units of fuel and price of $1.23/km

    new_taxi = Taxi("Prius 1", 100)
    print(new_taxi)

    # 2 - Drive the taxi 40km
    new_taxi.drive(40)
    print(new_taxi)

    # 3 - Print the taxi's details and the current fare

    print(new_taxi)
    print("name:", new_taxi.name)
    print("fuel", new_taxi.fuel)
    print("odometer", new_taxi.odometer)
    print("fare distance", new_taxi.current_fare_distance)
    print("fare $", new_taxi.price_per_km, "per/km")
    print("current fare: $", new_taxi.get_fare())

    # 4 - Restart the meter (start a new fare) and then drive the car 100km

    new_taxi.start_fare()
    # can only drive 60k due to fuel left
    new_taxi.drive(100)
    print(new_taxi)

    # 5 - Print the details and the current fare
    print(new_taxi)
    print("current fare: $", new_taxi.get_fare())

    # test class variable
    print(new_taxi.price_per_km)
Ejemplo n.º 19
0
def main():
    test_taxi = Taxi("Prius 1", 100)
    test_taxi.drive(40)
    print(test_taxi)
    test_taxi.start_fare()
    test_taxi.drive(100)
    print(test_taxi)
Ejemplo n.º 20
0
def main():
    total_bill = 0
    taxis = [
        Taxi('Prius', 100),
        SilverServiceTaxi('Limo', 100, 2),
        SilverServiceTaxi('Hummer', 200, 4)
    ]
    current_taxi = None
    print("Let's Drive!")
    menu_choice = input(MENU)
    while menu_choice != "q":
        if menu_choice == "c":
            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 ${}".format(current_taxi.name,
                                                     trip_cost))
            total_bill += trip_cost
        else:
            print("Invalid Option")
        print("Bill to date: ${:.2f}".format(total_bill))
        menu_choice = str(input(MENU))
    print("Total Trip Cost: ${:.2f}".format(total_bill))
    print("Taxis are now:")
    display_taxis(taxis)
Ejemplo n.º 21
0
def main():
    print("Let's drive!")
    option = menu()
    taxis = [Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2),
    SilverServiceTaxi("Hummer", 200, 4)]
    total_cost = 0
    while option != "q":
        if option == "c":
            print("Taxis available:")
            display_taxis(taxis)
            taxi_choice = int(input("Choose taxi: "))
            chosen_taxi = taxis[taxi_choice]
        elif option == "d":
            chosen_taxi.start_fare()
            get_drive_distance = float(input("Drive how far? "))
            chosen_taxi.drive(get_drive_distance)
            current_cost = chosen_taxi.get_fare()
            print("Your {} trip cost you ${:.2f}".format(chosen_taxi.name, current_cost))
            total_cost += current_cost
        else:
            print("Invalid input.")
        print("Bill to date: ${:.2f}".format(total_cost))
        option = menu()

    print("Total trip cost: ${:.2f}".format(total_cost))
    print("Taxis are now:")
    display_taxis(taxis)
Ejemplo n.º 22
0
def main():
    t = Taxi("Prius 1", 100)
    t.drive(40)
    print(t)
    t.start_fare()
    t.drive(100)
    print(t)
Ejemplo n.º 23
0
def main():
    """Initialise available taxis and constructs menu."""
    current_taxi = None
    current_bill = 0
    taxis = [Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4)]
    print("Let's drive!")
    menu_selection = ''
    while menu_selection != 'q':
        print("q)uit, c)hoose taxi, d)rive")
        menu_selection = input(">>> ")
        if menu_selection == 'c':
            current_taxi = choose_taxi(taxis)
            print("Bill to date: ${:.2f}".format(current_bill))
        elif menu_selection == 'd':
            try:
                cost_of_trip = commence_trip(current_taxi)
                print("Your {} trip cost you ${:.2f}".format(current_taxi.name, cost_of_trip))
                current_bill += cost_of_trip
                print("Bill to date: ${:.2f}".format(current_bill))
            except AttributeError:
                print("Please choose a taxi first.")
        elif menu_selection == 'q':
            print("Total trip cost: ${:.2f}\nTaxis are now:".format(current_bill))
            list_taxis(taxis)
        else:
            print("Please select a valid menu option:")
def main():

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

    print("Let's drive!")
    menu_choice = input("q)uit, c)hoose taxi, d)rive")
    print(menu_choice)
    if menu_choice != "q":
        if menu_choice == "c":
            print("Taxi available:")
            print(taxi)
            taxi_choice = int(input("Choose taxi: "))
            taxi_selected = [taxi_choice]
            print("Bill to date: {}".format(bill))
            print()

        else:
            distance = int(input("Drive how far?"))
            taxi.drive(distance)
            print("Your {} trip cost you ${}".format(taxi.name, taxi.get_fare))
            bill = bill + taxi.get_fare
            print("Bill to date: {}".format(bill))

    print("Total trip cost: ${}".format(bill))
    print("Taxis are now:")
    print(taxi)
Ejemplo n.º 25
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)
            # no error-checking
            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)
Ejemplo n.º 26
0
def main():
    taxis = [
        Taxi("Prius", 100),
        SilverServiceTaxi("Limo", 100, 2),
        SilverServiceTaxi("Hummer", 200, 4)
    ]
    current_taxi = ''
    bill = 0.00
    user_input = input('q)uit, c)hoose taxi, d)rive\n>>> ').strip().lower()
    while user_input != 'q':
        if user_input == 'c':
            for i, taxi in enumerate(taxis):
                print('{0} - {1}'.format(i, str(taxi)))
            current_taxi = get_taxi(taxis)
        elif user_input == 'd':
            if current_taxi == '':
                print('A taxi must be selected before driving!')

            else:
                taxis[current_taxi].drive(
                    get_drive_distance(current_taxi, taxis))
                bill += taxis[current_taxi].get_fare()
                print('Your {0} trip cost you ${1}\nBill to date: ${2}'.format(
                    taxis[current_taxi].name, taxis[current_taxi].get_fare(),
                    bill))
        elif user_input != 'c' or 'd' or 'q':
            print('Enter a valid choice')
        user_input = input('q)uit, c)hoose taxi, d)rive\n>>> ').strip().lower()
Ejemplo n.º 27
0
def main():
    taxis = [Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2), SilverServiceTaxi("Hummer", 200, 4)]
    bill = 0
    current_taxi = None
    print("Let's drive!")
    print(MENU)
    choice = input('>>> ').upper()
    while choice != 'Q':
        if choice == 'C':
            print("Taxis available:")
            for i, taxi in enumerate(taxis):   # The price_per_km in example 1.20 not 1.23
                print('{} - {}'.format(i,taxi))
            current_taxi = int(input('Choose taxi: '))
            print('Bill to date: ${:.2f}'.format(bill))
        if choice == 'D':
            if current_taxi != None:
                drive_distance = int(input('Drive how far? '))
                taxis[current_taxi].drive(drive_distance)  # This updates self.current_fare_distance for driven distance
                cost_of_trip = taxis[current_taxi].get_fare()
                print('Your {} trip cost you ${:.2f}'.format(taxis[current_taxi].name,cost_of_trip))
                bill += cost_of_trip
                print('Bill to date: ${:.2f}'.format(bill))
        print(MENU)
        choice = input('>>> ').upper()
    print('Total trip cost: ${:.2f}'.format(bill))
    print('Taxis are now:')
    for i, taxi in enumerate(taxis):  # The price_per_km in example 1.20 not 1.23
        print('{} - {}'.format(i, taxi))
def main():
    taxis = [ Taxi("Prius", 100), SilverServiceTaxi("Limo", 100, 2),
              SilverServiceTaxi("Hummer", 200, 4) ]

    taxis = [ (i, j) for i, j in enumerate(taxis) ]

    def print_taxis(list_of_taxis):
        for taxi in taxis:
            print("{} - {}".format(taxi[ 0 ], taxi[ 1 ]))

    print("Lets Drive!")
    print(MENU)
    choice = ""
    total_bill = 0
    current_car = [ ]
    while choice != "Q":
        choice = input("Enter Menu Choice: ").upper()
        if choice == "C":
            print_taxis(taxis)
            taxi_selection = int(input("Enter Taxi number to ride: "))
            current_car = taxis[ taxi_selection ][ 1 ]
            print("Bill to date is ${}".format(total_bill))
        elif choice == "D":
            current_car.start_fare()
            drive_distance = int(input("How far do you want to drive: "))
            current_car.drive(drive_distance)
            total_bill += current_car.get_fare()
            print("Your {} trip cost you ${}".format(current_car.name, current_car.get_fare()))
            print("Bill to date is ${}".format(total_bill))
    print("Total trip cost: ${}".format(total_bill))
    print("Taxis are now")
    print_taxis(taxis)
Ejemplo n.º 29
0
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())
Ejemplo n.º 30
0
def main():
    my_taxi = Taxi("Prius 1", 100)
    my_taxi.drive(40)
    print(my_taxi)
    my_taxi.start_fare()
    my_taxi.drive(100)
    print(my_taxi)