コード例 #1
0
def main():
    taxi = Taxi("Prius 1", 100, 1.23)
    taxi.drive(40)
    print(taxi)
    taxi.start_fare()
    taxi.drive(100)
    print(taxi)
コード例 #2
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())
コード例 #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())
コード例 #4
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)
コード例 #5
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)
コード例 #6
0
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)
コード例 #7
0
def tests():
    car = Car("Datsun", 180)
    car.drive(30)
    print("fuel =", car.fuel)
    print("odo =", car.odometer)
    car.drive(55)
    print("fuel =", car.fuel)
    print("odo = ", car.odometer)
    print(car)

    distance = int(input("Drive how far? "))
    while distance > 0:
        travel = car.drive(distance)
        print("{} travelled {}".format(str(car), travel))
        distance = int(input("Drive how far? "))

    taxis = Taxi("Prius 1", 100)
    taxis.drive(25)
    print(taxis)
    print(taxis, taxis.get_fare())
    taxis.start_fare()
    taxis.drive(40)
    print(taxis, taxis.get_fare())

    silver_service_taxi = SilverServiceTaxi("Limo", 100, 2)
    print(silver_service_taxi, silver_service_taxi.get_fare())
    silver_service_taxi.drive(10)
    print(silver_service_taxi, silver_service_taxi.get_fare())
コード例 #8
0
ファイル: taxi_test.py プロジェクト: AengusDavies/Practicals
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)
コード例 #9
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)
コード例 #10
0
ファイル: taxi_test.py プロジェクト: Baljeet97/prac_08
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)
コード例 #11
0
def main():
    t = Taxi("Prius 1", 100)
    t.drive(40)
    print(t)
    t.start_fare()
    t.drive(100)
    print(t)
コード例 #12
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)
コード例 #13
0
def main():
    taxi = Taxi("Prius 1", 100)
    taxi.drive(40)
    print("{}, Fare: ${}".format(taxi, taxi.get_fare()))
    taxi.start_fare()
    taxi.drive(100)
    print("{}, Fare: ${}".format(taxi, taxi.get_fare()))
コード例 #14
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())
コード例 #15
0
def main():
    my_taxi = Taxi("Prius 01", 100)
    my_taxi.drive(40)
    print(my_taxi, "${:.2f}".format(my_taxi.get_fare()))
    my_taxi.start_fare()
    my_taxi.drive(100)
    print(my_taxi, "${:.2f}".format(my_taxi.get_fare()))
コード例 #16
0
def main():
    prius = Taxi("Prius 1", 100)
    prius.drive(40)
    print("{}, (${})".format(prius.__str__(), prius.get_fare()))
    prius.start_fare()
    prius.drive(100)
    print("{}, (${})".format(prius.__str__(), prius.get_fare()))
コード例 #17
0
def main():
    prius_1 = Taxi("Prius 1", 100)
    prius_1.drive(40)
    print(prius_1)
    prius_1.start_fare()
    prius_1.drive(100)
    print(prius_1)
コード例 #18
0
def main():
    """Demo test code to show how to use car class."""
    taxi = Taxi("Prius 1", 100)
    taxi.drive(40)
    print("{}\n${}".format(taxi, taxi.get_fare()))
    taxi.start_fare()
    taxi.drive(100)
    print("${}".format(taxi.get_fare()))
コード例 #19
0
def main():
    """Test Taxi class"""
    taxi = Taxi("Prius 1", 100)
    taxi.drive(40)
    print(taxi)
    taxi.start_fare()
    taxi.drive(100)
    print(taxi)
コード例 #20
0
def main():
    new_taxi = Taxi("Prius 1", 100)
    new_taxi.drive(40)
    current_fare = new_taxi.get_fare()
    print("{}, ${}".format(new_taxi, current_fare))
    new_taxi.start_fare()
    current_fare = new_taxi.get_fare()
    print("{}, ${}".format(new_taxi, current_fare))
コード例 #21
0
def main():
    """Test taxi class"""
    my_taxi = Taxi("Prius 1", 100)
    my_taxi.drive(40)
    print("{}, Current fare: ${}".format(my_taxi, my_taxi.get_fare()))
    my_taxi.start_fare()
    my_taxi.drive(100)
    print("{}, Current fare: ${}".format(my_taxi, my_taxi.get_fare()))
コード例 #22
0
def testing():
    taxi = Taxi("Prius 1", 100)
    taxi.drive(40)
    print(taxi)

    taxi.start_fare()
    taxi.drive(100)
    print(taxi)
コード例 #23
0
def main():
    """Test Taxi class."""
    new_taxi = Taxi("Prius 1", 100)
    new_taxi.drive(40)
    print(new_taxi)
    new_taxi.start_fare()
    new_taxi.drive(100)
    print(new_taxi)
コード例 #24
0
def main():
    """Test the taxi and car classes."""
    taxi = Taxi('Prius 1', 100)
    taxi.drive(40)
    print("{} Total: ${:.2f}".format(taxi, taxi.get_fare()))
    taxi.start_fare()
    taxi.drive(100)
    print("{} Total: ${:.2f}".format(taxi, taxi.get_fare()))
コード例 #25
0
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)
コード例 #26
0
def main():
    taxi = Taxi("Prius 1", 100)
    taxi.drive(40)
    print(taxi)
    taxi.start_fare()
    taxi.drive(100)
    print(taxi)
    print("Total fare is: ${:.2f}".format(taxi.get_fare()))
コード例 #27
0
def main():
    taxi = Taxi("Prius 1",100)
    taxi.drive(40)
    print(taxi)
    taxi.start_fare()
    taxi.add_fuel(60)
    taxi.drive(100)
    print(taxi)
コード例 #28
0
def main():
    prius_1 = Taxi('Prius 1', 100)
    prius_1.drive(40)
    print(prius_1)
    print("Current Fare: ${:.2f}".format(prius_1.get_fare()))
    prius_1.start_fare()
    prius_1.drive(100)
    print(prius_1)
    print("Current Fare: ${:.2f}".format(prius_1.get_fare()))
コード例 #29
0
def main():
    """"run the test code"""
    my_taxi = Taxi("Prius 1", 100)
    my_taxi.drive(40)
    print_fare_details(my_taxi)
    my_taxi.start_fare()
    my_taxi.add_fuel(40)
    my_taxi.drive(100)
    print_fare_details(my_taxi)
コード例 #30
0
def main():
    """Test for the Taxi class"""
    prius = Taxi("Prius 1", 100)
    prius.drive(40)
    print(prius)
    print("Fare = $", prius.get_fare())
    prius.start_fare()
    print(prius)
    print("Fare = $", prius.get_fare())