Exemplo n.º 1
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()))
Exemplo 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()
Exemplo n.º 3
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)
Exemplo n.º 4
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()))
Exemplo n.º 5
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.º 6
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())
Exemplo n.º 7
0
def main():
    new_taxi = Taxi("Prius 1", 100)
    new_taxi.drive(40)
    print(new_taxi, new_taxi.get_fare())
    new_taxi.start_fare()
    new_taxi.drive(100)
    print(new_taxi, new_taxi.get_fare())
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())
Exemplo n.º 9
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()))
Exemplo n.º 10
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()))
Exemplo n.º 11
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()))
Exemplo n.º 12
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)
Exemplo n.º 13
0
def main():
    taxi = Taxi("Prius 1", 100)
    taxi.drive(40)
    print(taxi)
    print(taxi.get_fare())
    taxi.start_fare()
    taxi.drive(100)
    print(taxi)
    print(taxi.get_fare())
Exemplo n.º 14
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()))
Exemplo n.º 15
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)
Exemplo n.º 16
0
def main():
    my_taxi = Taxi('Prius 1', 100)
    my_taxi.drive(40)
    print(my_taxi)
    print('Current fare cost is', my_taxi.get_fare())
    my_taxi.start_fare()
    my_taxi.drive(100)
    print(my_taxi)
    print('Current fare cost is', my_taxi.get_fare())
Exemplo n.º 17
0
def main():
    my_taxi = Taxi("Prius 1", 100)
    my_taxi.drive(40)
    print(my_taxi)
    print(my_taxi.get_fare())
    my_taxi.start_fare()
    my_taxi.drive(100)
    print(my_taxi)
    print(my_taxi.get_fare())
Exemplo n.º 18
0
def main():
    taxi1 = Taxi('Prius 1', 100)
    taxi1.drive(40)
    print(taxi1)
    print("${}".format(taxi1.get_fare()))
    taxi1.start_fare()
    taxi1.drive(100)
    print(taxi1)
    print("${}".format(taxi1.get_fare()))
Exemplo n.º 19
0
def main():
    new_taxi = Taxi('Prius 1', 100)
    new_taxi.drive(40)
    print(new_taxi)
    print('Current Fare:', new_taxi.get_fare())
    new_taxi.start_fare()
    new_taxi.drive(100)
    print(new_taxi)
    print('Current Fare:', new_taxi.get_fare())
Exemplo n.º 20
0
def main():
    prius = Taxi("Prius 1", 100)
    prius.drive(40)
    print(prius)
    print(prius.get_fare())

    prius.start_fare()
    prius.drive(100)
    print(prius)
    print(prius.get_fare())
Exemplo n.º 21
0
def main():
    taxi1 = Taxi("Prius 1", 100, 1.23)

    taxi1.drive(40)
    print(taxi1)
    print("The current fare is ${}".format(taxi1.get_fare()))
    taxi1.start_fare()
    taxi1.drive(100)
    print(taxi1)
    print("The current fare is ${}".format(taxi1.get_fare()))
Exemplo n.º 22
0
def main():
    print("Taxi Testing")
    new_taxi = Taxi("Prius 1", 100)
    new_taxi.drive(40)
    print(new_taxi)
    print("The price of that trip was {}".format(new_taxi.get_fare()))
    new_taxi.start_fare()
    new_taxi.drive(100)
    print(new_taxi)
    print("The price of that trip was {}".format(new_taxi.get_fare()))
Exemplo n.º 23
0
def main():
    """Code to test out taxi class"""
    taxi = Taxi("Prius 1", 100)
    taxi.drive(40)
    print(taxi)
    print("Fare: $" + str(taxi.get_fare()))
    taxi.start_fare()
    taxi.drive(100)
    print(taxi)
    print("Fare: $" + str(taxi.get_fare()))
Exemplo n.º 24
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: ${}".format(prius.get_fare()))
Exemplo n.º 25
0
def main():
    taxi = Taxi("Prius 1", 100)
    print(taxi)
    taxi.drive(40)
    print(taxi)
    print("Current fare ${:.2f}".format(taxi.get_fare()))
    taxi.start_fare()
    taxi.drive(100)
    print(taxi)
    print("Current fare ${:.2f}".format(taxi.get_fare()))
Exemplo n.º 26
0
def main():

    taxi = Taxi("Prius 1", 100)
    taxi.drive(40)
    print("taxi name =", taxi.name)
    print("current fare = $", taxi.get_fare())
    taxi.start_fare()
    taxi.drive(100)
    print("taxi name =", taxi.name)
    print("current fare = $", taxi.get_fare())
Exemplo n.º 27
0
def main():
    """Test Taxi."""
    prius_1 = Taxi("Prius 1", 100)
    prius_1.drive(40)
    print(prius_1)
    print("Current fare is ${}".format(prius_1.get_fare()))

    prius_1.start_fare()
    prius_1.drive(100)
    print(prius_1)
    print("Current fare is ${}".format(prius_1.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))
Exemplo n.º 29
0
def main():
    """Test code for Taxi class."""
    my_taxi = Taxi("Prius 1", 100)
    my_taxi.drive(40)
    print("fuel =", my_taxi.fuel)
    print("odo =", my_taxi.odometer)
    print("Fare = ${:.2f}".format(my_taxi.get_fare()))
    my_taxi.start_fare()
    my_taxi.drive(100)
    print(my_taxi)
    print("Fare = ${:.2f}".format(my_taxi.get_fare()))
Exemplo n.º 30
0
def main():
    """Test the Taxi class"""
    new_taxi = Taxi("Prius 1", 100)
    new_taxi.drive(40)
    print(new_taxi)
    print(new_taxi.get_fare())

    new_taxi.start_fare()
    new_taxi.drive(100)
    print(new_taxi)
    print(new_taxi.get_fare())