Exemple #1
0
 def test_car_wheels(self):
     man = car_class.Car('MAN', 'Truck', 'trailer')
     koenigsegg = car_class.Car('Koenigsegg', 'Agera R')
     self.assertEqual(
         [8, 4], [man.num_of_wheels, koenigsegg.num_of_wheels],
         msg=
         'The car shoud have four (4) wheels except its a type of trailer')
 def test_car_doors(self):
     opel = car_class.Car('Opel', 'Omega 3')
     porshe = car_class.Car('Porshe', '911 Turbo')
     self.assertListEqual([opel.num_of_doors,
                           porshe.num_of_doors,
                           car_class.Car('Koenigsegg', 'Agera R').num_of_doors],
                          [4, 2, 2],
                          msg='The car shoud have four (4) doors except its a Porshe or Koenigsegg')
def main():
    #Asking user for the car model_year and make
    model = input('Enter the model year of the car: ')
    make = input('Enter the make of the car: ')
    speed = 0
    #Creating a Car object
    car = car_class.Car(make, model, speed)
    print()

    #Displaying current speed before calling
    #the accelerate method
    print('Current speed is:', car.get_speed())

    #Callin the accelerate method five times
    print('Displaying current speed for each of the five '
          'calls to the accelerate method.')
    for count in range(1, 6):
        car.accelerate()
        print('Current Speed', count, ':', car.get_speed())
    print()

    #Displaying current speed before calling
    #the brake method
    print('Current speed is:', car.get_speed())
    print('Displaying current speed for each of the five '
          'calls to the brake method.')
    for count in range(1, 6):
        car.brake()
        print('Curretn Speed', count, ':', car.get_speed())
Exemple #4
0
 def test_default_car_model(self):
     gm = car_class.Car()
     self.assertEqual(
         'GM',
         gm.model,
         msg=
         "The car's model should be called `GM` if no model was passed as an argument"
     )
Exemple #5
0
 def test_default_car_name(self):
     gm = car_class.Car()
     self.assertEqual(
         'General',
         gm.name,
         msg=
         'The car should be called `General` if no name was passed as an argument'
     )
 def test_drive_car(self):
     man = car_class.Car('MAN', 'Truck', 'trailer')
     moving_man = man.drive(7)
     moving_man_instance = isinstance(moving_man, car_class.Car)
     moving_man_type = type(moving_man) is car_class.Car
     self.assertListEqual([True, True, man.speed],
                          [moving_man_instance, moving_man_type, moving_man.speed],
                          msg='The car drive function should return the instance of the Car class')
    def test_car_speed2(self):
        man = car_class.Car('Mercedes', 'SLR500')
        parked_speed = man.speed
        moving_speed = man.drive(3).speed

        self.assertListEqual([parked_speed, moving_speed],
                             [0, 1000],
                             msg='The Mercedes should have speed 0 km/h until you put `the pedal to the metal`')
    def test_car_speed(self):
        man = car_class.Car('MAN', 'Truck', 'trailer')
        parked_speed = man.speed
        moving_speed = man.drive(7).speed

        self.assertListEqual([parked_speed, moving_speed],
                             [0, 77],
                             msg='The Trailer should have speed 0 km/h until you put `the pedal to the metal`')
Exemple #9
0
#from car_class import *
import car_class

car = car_class.Car('audi', 'a4', 2016)
print(car.get_desciptive_name())
car.read_odometer()
car.update_odometer(23)
car.read_odometer()

my_tesla = car_class.ElectricCar('tesla', 'model s', 2016)
print(my_tesla.get_desciptive_name())
my_tesla.read_odometer()
my_tesla.battery = car_class.Battery(80)
my_tesla.battery.describe_battery()
Exemple #10
0
 def test_car_type(self):
     koenigsegg = car_class.Car('Koenigsegg', 'Agera R')
     self.assertTrue(
         koenigsegg.is_saloon(),
         msg='The car type should be saloon if it is not a trailer')
Exemple #11
0
 def test_car_instance(self):
     honda = car_class.Car('Honda')
     self.assertIsInstance(
         honda,
         car_class.Car,
         msg='The object should be an instance of the `Car` class')
Exemple #12
0
 def test_car_properties(self):
     toyota = car_class.Car('Toyota', 'Corolla')
     self.assertListEqual(
         ['Toyota', 'Corolla'], [toyota.name, toyota.model],
         msg='The car name and model should be a property of the car')
Exemple #13
0
 def test_object_type(self):
     honda = car_class.Car('Honda')
     self.assertTrue((type(honda) is car_class.Car),
                     msg='The object should be a type of `Car`')
import car_class

my_new_car = car_class.Car('audi', 'a4', 2019)
print(my_new_car.get_descriptive_name())

my_new_car.odometer_reading = 23
print(my_new_car.get_descriptive_name())

import car_class as CC

my_new_car_5 = CC.Car('audi', 'a5', 2019)
print(my_new_car_5.get_descriptive_name())

from car_class import Car

my_new_car_2 = Car('audi', 'a4', 2018)
print(my_new_car_2.get_descriptive_name())

from electric_car import ElectricCar

my_new_car_3 = ElectricCar('audi', 'a4', 2019, 150)
my_new_car_3.battery.get_battery_size()

from electric_car import ElectricCar as EC

my_new_car_6 = EC('audi', 'a4', 2019, 200)
my_new_car_6.battery.get_battery_size()

from electric_car import *

my_new_car_4 = Battery(350)
Exemple #15
0
def main():
    model_year = input("Enter the Car Year Model: ")
    make = input("Enter the car Make:")
    car = car_class.Car(model_year, make)
    accele(car)
    brake(car)