Ejemplo n.º 1
0
def golimo():
    limo = Car("Limo", 100)
    limo.add_fuel(20)
    print("Current fuel is {}".format(limo.fuel))
    limo.drive(115)
    print("Odo is {}".format(limo.odometer))
    print(limo)
Ejemplo n.º 2
0
def main():
    limo = Car(100,  "abc")
    limo.add_fuel(20)
    print("fuel = ", limo.fuel)
    limo.drive(115)
    print("odometer = ", limo.odometer)
    print(limo)
Ejemplo n.º 3
0
def main():
    limo = Car(100, "abc")
    limo.add_fuel(20)
    print("fuel = ", limo.fuel)
    limo.drive(115)
    print("odometer = ", limo.odometer)
    print(limo)
Ejemplo n.º 4
0
def limo():
    limo=Car(100,"limo")
    limo.add_fuel(20)
    print("fuel =", limo.fuel)
    limo.drive(115)
    print("odo =", limo.odometer)
    print(limo)
Ejemplo n.º 5
0
def main():
    limo = Car('limo', 100)
    limo.add_fuel(20)
    print(limo.fuel)
    limo.drive(115)
    print(limo.odometer)
    print(limo)
Ejemplo n.º 6
0
def limo():
    limo = Car(100, "limo")
    limo.add_fuel(20)
    print("fuel =", limo.fuel)
    limo.drive(115)
    print("odo =", limo.odometer)
    print(limo)
def main(fuel=None):
    """Demo test code to show how to use car class."""
    my_car = Car(180)
    my_car.drive(30)
    my_car.car_name = "Ford GT"

    # -----------------------------------------------------------------#
    limo = Car(100)  # add a limo car, with 100 fuel
    limo.car_name = "Chrysler 300 Limo"
    # -----------------------------------------------------------------#
    print("fuel =", my_car.fuel)
    print("odo =", my_car.odometer)

    print(my_car)

    # -----------------------------------------------------------------#
    print("fuel =", limo.fuel)
    print("odo =", limo.odometer)  # print the Car limo's details
    print(limo)

    # -----------------------------------------------------------------#
    limo.add_fuel(20)  # add 20 fuel to the limo using add_fuel method
    # -----------------------------------------------------------------#
    print("fuel =", limo.fuel)
    # -----------------------------------------------------------------#
    limo.drive(115)  # drive the car 155km
    print("fuel =", limo.fuel)  # display the fuel and odometer
    print("odo =", limo.odometer)
    print(limo)
    # -----------------------------------------------------------------#

    # -----------------------------------------------------------------#

    print("Car {}, {}".format(my_car.fuel, my_car.odometer))
    print("Car {self.fuel}, {self.odometer}".format(self=my_car))
Ejemplo n.º 8
0
def the_good_stuff():
    car_limo = Car("Limo", 100)
    print(car_limo)
    car_limo.add_fuel(20)
    print(car_limo)
    car_limo.drive(115)
    print(car_limo)
Ejemplo n.º 9
0
def main():
    """Demo test code to show how to use car class."""
    my_car = Car(180)
    my_car.drive(30)
    print("fuel =", my_car.fuel)
    print("odo =", my_car.odometer)
    print(my_car)

    print("Car {}, {}".format(my_car.fuel, my_car.odometer))
    print("Car {self.fuel}, {self.odometer}".format(self=my_car))
    print(
        "---------------------------------------------------------------------------"
    )

    limo = Car(
        "Limo", 100
    )  # Create a new Car object called "limo" that is initialised with 100 units of fuel.
    limo.add_fuel(
        20
    )  # Add 20 more units of fuel to this new car object using the add method.
    print("Limo's fuel = ", limo.fuel)  # Print the amount of fuel in the car.
    limo.drive(115)  # Attempt to drive the car 115km using the drive method.
    print("Limo's odometer: ",
          limo.odometer)  # Print the car's odometer reading.
    print(limo)
Ejemplo n.º 10
0
def main():
    print("Let's drive!")
    car_name = input("Enter your car name: ")
    car = Car(car_name)

    choice = "A"
    while choice != "Q":
        print(car)
        choice = input(
            "Menu \n (D)rive \n (R)efuel \n (Q)uit \nEnter your choice: "
        ).upper()
        if choice == "D":
            validated = False
            while not validated:
                distance = input("How many km do you wish to drive?: ")
                validated = validate_number_positive(distance)
            distance = int(distance)
            car.drive(distance)

        elif choice == "R":
            validated = False
            while not validated:
                fuel = input(
                    "How many units of fuel do you want to add to the car?: ")
                validated = validate_number_positive(fuel)
            fuel = int(fuel)
            car.add_fuel(fuel)

    print("Goodbye {}'s driver".format(car_name))
Ejemplo n.º 11
0
def main():
    limo = Car("limo", 180)
    limo.add_fuel(30)
    limo.drive(115)

    print("limo odometer", limo.odometer)
    print("limo fuel:", limo.fuel)
    print("{}, fuel={}, odometer={}".format(limo.name, limo.fuel, limo.odometer))
Ejemplo n.º 12
0
def limo():
    my_limo = Car(100)
    my_limo.add_fuel(20)
    print("fuel =", my_limo.fuel)
    my_limo.drive(115)
    print("odo =", my_limo.odometer)
    print("Limo")
    print(my_limo)
Ejemplo n.º 13
0
def main():
    bus = Car(180, "Bus")
    bus.drive(30)
    print(bus)

    limo = Car(100,"Limo")
    limo.add_fuel(20)
    limo.drive(115)
    print(limo)
Ejemplo n.º 14
0
def main():
    bus = Car("bus", 180)
    bus.drive(30)
    print(bus)

    limo = Car("limo", 100)
    limo.add_fuel(20)
    limo.drive(115)
    print(limo)
Ejemplo n.º 15
0
def main():
    bus = Car("bus",180)
    bus.drive(30)
    print(bus)

    limo = Car("limo", 100)
    limo.add_fuel(20)
    limo.drive(115)
    print(limo)
Ejemplo n.º 16
0
def main():

    bus = Car(180, 'bus')
    bus.add_fuel(20)
    bus.drive(30)
    print(bus)

    limo = Car(120, "limo")
    limo.drive(115)
    print(limo)
Ejemplo n.º 17
0
def main():
    my_car = Car("limo", 100)
    my_car.add_fuel(20)
    my_car.drive(100)
    print("fuel =", my_car.fuel)
    print("odo =", my_car.odometer)
    print(my_car)

    print("Car {}, {}".format(my_car.fuel, my_car.odometer))
    print("Car {self.fuel}, {self.odometer}".format(self=my_car))
Ejemplo n.º 18
0
def main():
    bus = Car("Bus", 180)
    bus.drive(30)
    print("fuel =", bus.fuel)
    print("odo =", bus.odometer)
    print(bus)
    limo = Car("Limo", 100)
    limo.add_fuel(20)
    print("fuel =", limo.fuel)
    limo.drive(115)
    print("odo =", limo.odometer)
Ejemplo n.º 19
0
def main():
    bus = Car("Bus", 180)
    bus.drive(30)
    print("fuel =", bus.fuel)
    print("odo =", bus.odometer)
    print(bus)
    limo = Car("Limo", 100)
    limo.add_fuel(20)
    print("fuel =", limo.fuel)
    limo.drive(115)
    print("odo =", limo.odometer)
Ejemplo n.º 20
0
def main():
    bus = Car(180)
    bus.drive(30)
    print("fuel =", bus.fuel)
    print("odo =", bus.odometer)
    print(bus)

    limo = Car(100)
    limo.add_fuel(20)
    print('fuel=', limo.fuel)
    limo.drive(115)
    print(limo.odometer)
Ejemplo n.º 21
0
def main():
    # bus = Car(180)
    # bus.drive(30)
    # print("fuel =", bus.fuel)
    # print("odo =", bus.odometer)
    # print(bus)

    limo = Car(100)
    limo.add_fuel(20)
    print("limo's fuel = {}".format(limo.fuel))
    limo.drive(115)
    print("limo's odometer = {}".format(limo.odometer))
Ejemplo n.º 22
0
def main():
    # bus = Car(180)
    # bus.drive(30)
    # print("fuel =", bus.fuel)
    # print("odo =", bus.odometer)
    # print(bus)

    limo = Car(100)
    limo.add_fuel(20)
    print("limo's fuel = {}".format(limo.fuel))
    limo.drive(115)
    print("limo's odometer = {}".format(limo.odometer))
Ejemplo n.º 23
0
def main():
    """Demo test code to show how to use car class."""
    my_car = Car(180)
    my_car.drive(30)
    print("fuel =", my_car.fuel)
    print("odo =", my_car.odometer)
    print(my_car)

    my_limo = Car(100)
    my_limo.add_fuel(20)
    print("Limo has {} units of fuel left".format(my_limo.fuel))
    my_limo.drive(115)
    print("Limo's odometer is {}".format(my_limo.odometer))
Ejemplo n.º 24
0
def main():
    bus = Car(180, 'Bus')
    bus.drive(30)
    print("fuel =", bus.fuel)
    print("odo =", bus.odometer)
    print(bus)

    limo = Car(100, 'Limo')
    limo.add_fuel(20)
    print("fuel =", limo.fuel)
    limo.drive(115)
    print("odo =", limo.odometer)
    print(limo)
Ejemplo n.º 25
0
def main():
    bus = Car(180, "bus")
    bus.drive(30)
    print("fuel =", bus.fuel)
    print("odo =", bus.odometer)
    print(bus)

    limo = Car(100, "limo")
    limo.add_fuel(20)
    print("fuel=", limo.fuel)
    limo.drive(115)
    print("odometer=", limo.odometer)
    print(limo)
Ejemplo n.º 26
0
def main():
    bus = Car(180,'Bus')
    bus.drive(30)
    print("fuel =", bus.fuel)
    print("odo =", bus.odometer)
    print(bus)

    limo = Car(100,'Limo')
    limo.add_fuel(20)
    print("fuel =", limo.fuel)
    limo.drive(115)
    print("odo =", limo.odometer)
    print(limo)
Ejemplo n.º 27
0
def main():
    bus = Car(180, "Bus")
    bus.drive(30)
    # print("fuel =", bus.fuel)
    # print("odo =", bus.odometer)
    print(bus)

    limo = Car(100, "Limo")
    limo.add_fuel(20)
    # print("fuel = ", limo.fuel)
    limo.drive(115)
    # print("fuel after drive = ", limo.fuel)
    # print("odo = ", limo.odometer)
    print(limo)
Ejemplo n.º 28
0
def main():
    bus = Car(180, "Bus")
    bus.drive(30)
    print("fuel =", bus.fuel)
    print("odo =", bus.odometer)
    print(bus)
    print('')  #adds a blank space between bus and limo

    limo = Car(100, "Limo")
    limo.add_fuel(20)
    limo.drive(115)
    print("fuel =", limo.fuel)
    print("odo =", limo.odometer)
    print(limo)
Ejemplo n.º 29
0
def main():
    """Demo test code to show how to use car class."""
    my_car = Car(180)
    my_car.drive(30)
    print("fuel =", my_car.fuel)
    print("odo =", my_car.odometer)
    print(my_car)

    print("Car {}, {}".format(my_car.fuel, my_car.odometer))
    print("Car {self.fuel}, {self.odometer}".format(self=my_car))

    limo = Car(100, "limo")
    limo.add_fuel(20)
    limo.drive(115)
    print("\n", limo)
Ejemplo n.º 30
0
def main():
    """Demo test code to show how to use car class."""
    limo = Car("Car", 100)
    limo.add_fuel(20)
    print("The car has fuel:", limo.fuel)
    limo.drive(115)
    print(limo.odometer)
    my_car = Car("Car", 180)
    my_car.drive(30)
    print("fuel =", my_car.fuel)
    print("odo =", my_car.odometer)
    print(my_car)

    print("Car {}, {}".format(my_car.fuel, my_car.odometer))
    print("Car {self.fuel}, {self.odometer}".format(self=my_car))
def main():
    """Demo test code to show how to use car class."""
    my_car = Car(180)
    my_car.drive(30)
    print("fuel =", my_car.fuel)
    print("odo =", my_car.odometer)
    print(my_car)
    print("Car {}, {}".format(my_car.fuel, my_car.odometer))
    print("Car {self.fuel}, {self.odometer}".format(self=my_car))

    limo = Car("limo", 100)
    # print('{}'.format(limo.name))
    limo.add_fuel(20)
    print("the amount of fuel in the car is {}".format(limo.fuel))
    limo.drive(115)
    print(" the car's odometer reading is {}".format(limo.odometer))
Ejemplo n.º 32
0
def main():

    my_car = Car(180)
    my_car.drive(30)
    print("fuel =", my_car.fuel)
    print("odo =", my_car.odometer)
    print(my_car)

    print("Car {}, {}".format(my_car.fuel, my_car.odometer))
    print("Car {self.fuel}, {self.odometer}".format(self=my_car))

    limo = Car("Limo", 100)
    limo.add_fuel(20)
    print(limo.fuel)
    limo.drive(115)
    print(limo.odometer)
Ejemplo n.º 33
0
def main():
    """Demo test code to show how to use car class."""
    # my_car = Car(180, "Porsche")
    # my_car.drive(30)
    # print("fuel =", my_car.fuel)
    # print("odo =", my_car.odometer)
    # print(my_car)
    #
    # print("Car {}, {}".format(my_car.fuel, my_car.odometer))
    # print("Car {self.fuel}, {self.odometer}".format(self=my_car))
    """"" Demo Limo Car """
    limo = Car(100, "Porsche")
    limo.add_fuel(20)
    print("The amount of fuel in the car : {} ".format(limo.fuel))
    limo.drive(115)
    print("The car's odometer : {}".format(limo.odometer))
    print(limo)
Ejemplo n.º 34
0
def main():
    """Demo test code to show how to use car class."""
    my_car = Car("My Car", 180)
    my_car.drive(30)
    print("fuel =", my_car.fuel)
    print("odo =", my_car.odometer)
    print(my_car)

    print("Car {}, {}".format(my_car.fuel, my_car.odometer))
    print("Car {self.fuel}, {self.odometer}".format(self=my_car))

    Limo = Car("Limo", 100)
    Limo.add_fuel(20)
    Limo.drive(115)
    print("Limo Fuel: {}".format(Limo.fuel))
    print("Limo Distance: {}".format(Limo.odometer))
    print(Limo)
Ejemplo n.º 35
0
def main():
    bus = Car(100)
    bus.drive(40)
    print("fuel =", bus.fuel)
    print("odo =", bus.odometer)
    print(bus)

    limo = Car(1500)
    limo.add_fuel(20)
    print("fuel =", limo.fuel)
    print("odo =", limo.odometer)
    print(limo)

    limo2 = Car(19)
    limo2.drive(115)
    print("odo =", limo2.odometer)
    print(limo2)
Ejemplo n.º 36
0
def main():
    """Demo test code to show how to use car class."""
    my_car = Car('my car', 180)
    my_car.drive(30)
    print("fuel =", my_car.fuel)
    print("odo =", my_car.odometer)
    print(my_car)

    print("Car {}, {}".format(my_car.fuel, my_car.odometer))
    print("Car {self.fuel}, {self.odometer}".format(self=my_car))

    limo = Car('limo', 100)
    limo.add_fuel(20)
    print('Limo {self.fuel}'.format(self=limo))
    limo.drive(115)
    print('limo {self.odometer}'.format(self=limo))
    print(limo)
Ejemplo n.º 37
0
def main():
    """Demo test code to show how to use car class."""
    my_car = Car("My Car", 180)
    my_car.drive(30)
    print("fuel =", my_car.fuel)
    print("odo =", my_car.odometer)
    print(my_car)

    print("Car {}, {}".format(my_car.fuel, my_car.odometer))
    print("Car {self.fuel}, {self.odometer}".format(self=my_car))

    limo = Car("Limo", 100)
    limo.add_fuel(20)
    print("Limo fuel = {}".format(limo.fuel))
    limo.drive(115)
    print("Limo's odometer after driving = {}".format(limo.odometer))
    print("Limo's fuel after driving = {}".format(limo.fuel))
    print(limo)
Ejemplo n.º 38
0
def main():
    """Demo test code to show how to use car class."""

    my_car = Car("Lamborghini", 180)
    my_car.drive(30)
    print("fuel =", my_car.fuel)
    print("odo =", my_car.odometer)
    print(my_car)

    print("Car {}, {}".format(my_car.fuel, my_car.odometer))
    print("Car {self.fuel}, {self.odometer}".format(self=my_car))

    limo = Car("Ferrari", 100)
    limo.add_fuel(20)
    limo.drive(115)
    print(limo.fuel)
    print(my_car.odometer)
    print(limo)
Ejemplo n.º 39
0
def main():
    print("Let's drive!")
    name = input("Enter your car name:")
    car = Car(name, 100)
    print(car)
    print("""Menu:
d) drive
r) refuel
q) quit""")
    choice = input("Enter your choice:").lower()
    while choice != "q":
        if choice == "d":
            distance = int(input("How many km do you wish to drive? "))
            while distance < 0:
                print("Distance must be >= 0")
                distance = int(input("How many km do you wish to drive? "))
            distance = car.drive(distance)
            if distance < car.fuel:
                print("The car drove {}km.".format(distance))
            else:
                print(
                    "The car drove {}km and ran out of fuel.".format(distance))
        elif choice == "r":
            fuel_added = int(
                input("How many units of fuel do you want to add to the car?"))
            while fuel_added < 0:
                print("Fuel amount must be >= 0")
                fuel_added = int(
                    input(
                        "How many units of fuel do you want to add to the car?"
                    ))
            car.add_fuel(fuel_added)
            print("Added {} units of fuel.".format(fuel_added))
        else:
            print("Invalid choice")
        print()
        print(car)
        print("""Menu:
d) drive
r) refuel
q) quit""")
        choice = input("Enter your choice: ").lower()
    print()
    print("Good bye {}'s driver.".format(car.name))
Ejemplo n.º 40
0
def main():
    """Demo test code to show how to use car class."""

    my_car = Car("mazda", 80)
    my_car.drive(30)
    limo = Car("ford", 100)
    limo.add_fuel(20)
    print("fuel = ", limo.fuel)
    limo.drive(115)
    print("odometer reading = ", limo.odometer)
    print(limo)
    print("make = {}, fuel = {}, odometer reading = {}".format(
        limo.name, limo.fuel, limo.odometer))
    print("fuel =", my_car.fuel)
    print("odo =", my_car.odometer)
    print(my_car)

    print("Car {}, {}".format(my_car.fuel, my_car.odometer))
    print("Car {self.fuel}, {self.odometer}".format(self=my_car))