Exemplo n.º 1
0
 def init_vehicles(self):
     peugeot_206 = Car("Peugeot", "206", 200000.00, 4)
     honda_titan = Motorcycle("Honda", "Titan", 60000.00, 125)
     peugeot_208 = Car("Peugeot", "208", 250000.00, 5)
     yamaha_ybr = Motorcycle("Yamaha", "YBR", 80500.50, 160)
     tesla_s = ElectricCar("Tesla", "S", 300000.00, 2, "120v")
     return [peugeot_206, honda_titan, peugeot_208, yamaha_ybr, tesla_s]
Exemplo n.º 2
0
def test():
    car = Car("DaZhong", "module_1", 2016)
    print(car.get_descriptive_name())  # Dazhong,Module_1,2016

    electric_car = ElectricCar("DaZhong", "module_1", 2016)
    print(electric_car.get_descriptive_name())  # Dazhong,Module_1,2016

    electric_car.desc_battery()  # 70-kwh battery

    car.desc_type()  # Car
    electric_car.desc_type()  # Electric Car

    electric_car.battery.desc_battery()  # 70-kwh battery
Exemplo n.º 3
0
def main():
    # my_car = Car(color="black", make="Lexus", odometer=1000)
    # print("I'm a car!")
    # while True :
    #     action = input("What should I do? [A]ccelerate, [B]rake, \n"
    #                    "[Q]uit, [C]hange color, change [M]ake, \n"
    #                    "show [O]dometer, or show average [S]peed? ").upper()
    #     if action not in "ABOSQM" or len(action) != 1 :
    #         print("I don't know how to do that")
    #         continue
    #     if action == 'Q' :
    #         break
    #     if action == 'A' :
    #         my_car.accelerate()
    #     elif action == 'B' :
    #         my_car.brake()
    #     elif action == 'C':
    #         color = input("What color do you like? ")
    #         my_car.change_color(color)
    #     elif action == 'M':
    #         make = input("What make? ")
    #         my_car.change_model(make)
    #     elif action == 'O' :
    #         print("The car has driven {} kilometers".format(my_car.odometer))
    #     elif action == 'S' :
    #         print("The car's average speed was {} kph".format(
    #             my_car.average_speed()))
    #     my_car.step()
    #     my_car.say_state()
    #     my_car.describe()

    my_car = Car()
    my_car.describe()
    my_eCar = ElectricCar()
    my_eCar.describe()
    my_eCar.change_make('Porsche')
    my_eCar.describe()
    my_eCar.battery.change_battery(100, type='nickel')
    my_eCar.battery.range()
Exemplo n.º 4
0
from car import Car
from electric_car import ElectricCar

my_beetle = Car('volswagen', 'beetle', 2015, 9800)

my_tesla = ElectricCar('tesla', 'roadster', '2016', 970)

my_beetle.get_descriptive_name()

my_tesla.get_descriptive_name()

my_tesla.battery.about_battery()
Exemplo n.º 5
0
from car import Car
from electric_car import ElectricCar

clio = Car('Renault', 'Clio', '2015')
print(clio.get_descriptive_name())
clio.fill_gas_tank()

tesla = ElectricCar("Tesla", "Model X", "2018", 75)
print(tesla.get_descriptive_name())
# tesla.fill_gas_tank()
tesla.decribe_car_battery()
tesla.describe_range()
tesla.upgrade_battery()
tesla.decribe_car_battery()
tesla.describe_range()

# when you create a child class, the parent class must be part of the current
# and must appear before the child class in the file
Exemplo n.º 6
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#  my_cars.py
#
#  Copyright 2016 Maciej Olejnik <maciej@maciej-pc>

from car import Car
from electric_car import ElectricCar

my_car = Car('Jeep', 'Liberty', 2005, 101000)
print(my_car.get_descriptive_name())
# Zmiana wartości atrybutu egzemplarza bezpośrednio w egzemplarzu
#my_car.odometer_reading = 101000
# Uaktualnienie wartości atrybutu egzemplarza za pomocą metody
my_car.update_odometer(90000)
my_car.read_odometer()
my_car.increment_odometer(1000)
my_car.read_odometer()

print("\nTestowanie dziedziczenia klasy\n")

my_Tesla = ElectricCar("tesla", "model s", "2016", 100, 90)
print(my_Tesla.get_descriptive_name())
my_Tesla.update_odometer(300)
my_Tesla.read_odometer()
my_Tesla.battery.describe_battery()
my_Tesla.battery.get_range()
Exemplo n.º 7
0
from car import Car
from electric_car import ElectricCar

my_beetle = Car('volkswagen', 'beetle', 2015)
print(my_beetle.get_descriptive_name())

my_tesla = ElectricCar('tesla', 'roadster', 2015)
print(my_tesla.get_descriptive_name())
Exemplo n.º 8
0
from electric_car import Car, ElectricCar

my_beetle = Car('volkswagen','beetle',2019)
my_beetle.get_descriptive_name()

my_tesla = ElectricCar('tesla','roadster',2019)
my_tesla.get_descriptive_name()

# my_battery = Battery()
Exemplo n.º 9
0
# from car import Car, ElectricCar

# my_beetle = Car('volkswagen', 'beetle', 2019)
# print(my_beetle.get_descriptive_name())

# my_tesla = ElectricCar('tesla', 'roadster', 2019)
# print(my_tesla.get_descriptive_name())

# import car

# my_beetle = car.Car('volkswagen', 'beetle', 2019)
# print(my_beetle.get_descriptive_name())

# my_tesla = car.ElectricCar('tesla', 'roadster', 2019)
# print(my_tesla.get_descriptive_name())

# from car import Car
# from electric_car import ElectricCar

# my_beetle = Car('volkswagen', 'beetle', 2019)
# print(my_beetle.get_descriptive_name())

# my_tesla = ElectricCar('tesla', 'roadster', 2019)
# print(my_tesla.get_descriptive_name())

from electric_car import ElectricCar as EC

my_tesla = EC('tesla', 'roadster', 2019)
print(my_tesla.get_descriptive_name())
Exemplo n.º 10
0
from car import Car
from electric_car import ElectricCar

my_car = Car('Honda', 'a4', 2006)
my_car.descrip()

my_car = ElectricCar('Tesla', 'a5', 2016)
my_car.descrip()
Exemplo n.º 11
0
# set values
my_new_car.odometer_reading = 23
print(
    f"odometer reading for {my_new_car.get_description()} is {my_new_car.read_odometer()}"
)
my_new_car.read_odometer()

my_new_car.update_odometer(54)
print(
    f"odometer reading for {my_new_car.get_description()} is {my_new_car.read_odometer()}"
)

my_new_car.increment_odometer(20)
print(
    f"odometer reading for {my_new_car.get_description()} is {my_new_car.read_odometer()}"
)

# make sure I can read multiple classes from a single module
my_battery = Battery()
print(f"my batter = {my_battery}")

# inheritance
my_tesla = ElectricCar('tesla', 'model s', 2019)
print(
    f"odometer reading for {my_tesla.get_description()} is {my_tesla.read_odometer()}"
)
print(f"{my_tesla.battery.describe_battery()}")
my_tesla.battery.get_range()

my_new_car.fill_gas_tank()
my_tesla.fill_gas_tank()
Exemplo n.º 12
0
"""Your elec car"""

from electric_car import ElectricCar

your_elec_car = ElectricCar('fox', 'model-1', 2016)
your_elec_car.battery.describe_battery()
your_elec_car.battery.get_range()
Exemplo n.º 13
0
from electric_car import ElectricCar

my_tesla = ElectricCar("tesla", "model s", "2016")
print(my_tesla.get_descriptive_name())
Exemplo n.º 14
0
from electric_car import ElectricCar
from electric_car import Battery
"""
from electric_car import Car

my_new_car = Car('audi', 'a4', 2016)
print(my_new_car.get_descriptive_name())
my_new_car.odometer_reading = 23
my_new_car.read_odometer()
"""
battery = Battery()
new_my_el_car = ElectricCar('hz', 'r', 2011, battery=battery)
print(new_my_el_car.get_descriptive_name())

new_my_el_car.battery.get_range()
new_my_el_car.battery.upgrade_battery(240)
new_my_el_car.battery.get_range()
Exemplo n.º 15
0
from car import Car
from electric_car import ElectricCar

my_beetle = Car('volkswagen', 'beetle', 2016)
print(my_beetle.get_descriptive_name())

my_tesla = ElectricCar('tesla', "model s", '2020')
print(my_tesla.get_descriptive_name())
Exemplo n.º 16
0
from car import Car
from electric_car import ElectricCar as EC

my_used_car = Car('subaru', 'outback', 2015)
print(my_used_car.get_descriptive_name())

my_used_car.update_odometer(23_500)
my_used_car.read_odometer()

my_used_car.increment_odometer(100)
my_used_car.read_odometer()

my_telsa = EC('telsa', 'model s', 2019)
print(my_telsa.get_descriptive_name())
my_telsa.fill_gas_tank()
my_telsa.battery.describe_battery()
my_telsa.battery.get_range()
my_dog.roll_over()

from car import Car
my_car = Car('toyota', 'corolla', 2014)
print("My car is a " + my_car.get_name())
my_car.read_odometer()
my_car.odometer = 19200
my_car.read_odometer()
my_car.update_odometer(19283)
my_car.read_odometer()
my_car.increment_odometer(53)
my_car.read_odometer()
my_car.fill_gas_tank()

from electric_car import ElectricCar
my_electric_car = ElectricCar('nissan', 'leaf', 2017)
print(my_electric_car.get_name())
my_electric_car.battery.describe_battery()
my_electric_car.fill_gas_tank()
my_electric_car.battery.get_range()

import car
my_truck = car.Car('toyota', 'tacoma', 2016)
print(my_truck.get_name())

from user import User, Admin
user1 = User('arthur', 'schaffer')
print(user1.get_name())
print(user1.get_email())
user1.increment_login_attempts()
user1.increment_login_attempts()
Exemplo n.º 18
0
from car import Car
from electric_car import ElectricCar

my_beetle = Car("volkswagen", "beetle", 2019)
print(my_beetle.get_descriptive_name())

my_tesla = ElectricCar("tesla", "roadster", 2019)
print(my_tesla.get_descriptive_name())
Exemplo n.º 19
0
Arquivo: ex9-9.py Projeto: kbcmdba/pcc
# Battery Upgrade: Use the final version of electric_car.py from this section.
# Add a method to the Battery class called upgrade_battery(). This method
# should check the battery size and set the capacity to 85 if it isn't
# already. Make an electric car with a default battery size, call get_range()
# once, and then call get_range a second time after upgrading the battery.
# You should see an increase in the car's range.

from car import Car
from electric_car import Battery, ElectricCar

my_tesla = ElectricCar(2019, 'Tesla', 'Model S')
my_tesla.battery.get_range()
my_tesla.battery.upgrade_battery()
my_tesla.battery.get_range()

Exemplo n.º 20
0
# coding = uft-8
from electric_car import Car, ElectricCar

my_audi = Car('audi', 'A6L', 2016)
print(my_audi.car_describe())

my_tesla = ElectricCar('tesla', 'roadster', 2017)
print(my_tesla.car_describe())

my_tesla.battery.describe_battery()
my_tesla.battery.get_range()
Exemplo n.º 21
0
from electric_car import ElectricCar

my_tesla = ElectricCar('tesla', 'roadster', 2015)
print(my_tesla.battery.get_range())
my_tesla.battery.upgrade_battery()
print(my_tesla.battery.get_range())
from electric_car import ElectricCar

my_tesla = ElectricCar("tesla", "model x", 2020)

print(my_tesla.get_descriptive_name())
my_tesla.battery.describe_battery()
my_tesla.battery.get_range()
Exemplo n.º 23
0
from car import Car
from electric_car import ElectricCar

my_new_car = Car('nissan', 'qaskai', 2018)
print(my_new_car.get_descriptive_name())
my_new_car.odometer_reading = 29
my_new_car.read_odometer()
print()
my_tesla = ElectricCar('tesla', 'new 1', 2017)
print(my_tesla.get_descriptive_name())
my_tesla.battery.describe_battery()
my_tesla.battery.get_range()
Exemplo n.º 24
0
from electric_car import Car, ElectricCar
import electric_car
from car import *  # This import all class of module car

my_new_e_car = ElectricCar("Toyota", "Prius", "2018")
print(my_new_e_car.get_name())

my_new_car = Car("Maruti", "Swift", "2018")
print(my_new_car.get_name())

my_toyoto = electric_car.ElectricCar("Toyota", "Prius", "2018")
print(my_toyoto.get_name())

my_maruti = electric_car.Car("Maruti", "Swift", "2018")
print(my_maruti.get_name())
Exemplo n.º 25
0
from electric_car import ElectricCar

my_tesela = ElectricCar('tesela', 'model s', '2018')
my_tesela.battery.describe_battry()
print(my_tesela.get_descriptive_name())
Exemplo n.º 26
0
from car import Car
from electric_car import ElectricCar

my_new_car = Car('bmw', 'm3', 2018)

print(my_new_car.get_descriptive_name())

my_new_elcar = ElectricCar('Tesla', 'Roadster', 2016)

print(my_new_elcar.get_descriptive_name())
Exemplo n.º 27
0
from car import Car
from electric_car import ElectricCar

my_beetle = Car('volkswagen', 'beetle', 2016)
print(my_beetle.get_descriptive_name())

my_tesla = ElectricCar('tesla', 'model s', 2016)
print(my_tesla.get_descriptive_name())

my_tesla.fill_gas_tank()
my_tesla.battery.describe_battery()
my_tesla.battery.get_range()

my_tesla.battery.upgrade_battery()
my_tesla.battery.get_range()

my_tesla.battery.upgrade_battery()
my_tesla.battery.get_range()
Exemplo n.º 28
0
from electric_car import ElectricCar

my_tesla = ElectricCar('tesla', 'model s', 2016, 100)
print(my_tesla.get_descriptive_name())
my_tesla.describe_battery()
my_tesla.fill_gas_tank(50)
#my_tesla.read_gas_tank()
from electric_car import ElectricCar

my_tesla = ElectricCar('tesla', 'model s', 2016)
print(my_tesla.get_descriptive_name())
my_tesla.battery.describe_battery()
my_tesla.battery.get_range()


Exemplo n.º 30
0
from car import Car
from electric_car import ElectricCar,Battery
# import car
# from car import * # here importing all classes from a module

# my_new_car = car.Car('vlokswagen,'beatle',2016)
# print(my_new_car.get_descriptive_name())
my_new_car = Car('audi','a4',2016)
print(my_new_car.get_descriptive_name())
my_new_car.increment_odometer(70)
my_new_car.read_odometer()

# my_tesla = car.ElectricCar('tesla','roadster',2016)
# print(my_tesla.get_descriptive_name())
my_tesla = ElectricCar('audi','m4',2020)
my_tesla.describe_battery()
my_tesla.fill_gas_tank()
print(my_tesla.get_descriptive_name())
my_tesla.battery.describe_battery()
my_tesla.battery.get_range()

Exemplo n.º 31
0
# Page 181
# Импортирование модуля в модуль

from basic_car import Car
from electric_car import ElectricCar

my_beetle = Car('volkswagen', 'beetle', 2016)
print(my_beetle.get_descriptive_name())
# 2016 Volkswagen Beetle

my_tesla = ElectricCar('tesla', 'roadster', 2016)
print(my_tesla.get_descriptive_name())
# 2016 Tesla Roadster
Exemplo n.º 32
0
from electric_car import ElectricCar

my_tesla = ElectricCar("tesla", "model s", 2016)

print(my_tesla.get_descriptive_name())

my_tesla.describe_battery()

my_tesla.fill_gas_tamk()

my_tesla.battery.describe_battery()

my_tesla.battery.get_range()