def test_car_properties(self): toyota = Car('Toyota', 'Corolla') self.assertListEqual( ['Toyota', 'Corolla'], [toyota.name, toyota.model], msg='The car name and model should be a property of the 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)
def test_object_type(self): honda = Car('Honda') self.assertTrue((type(honda) is Car), msg='The object should be a type of `Car`')
def test_car_type(self): koenigsegg = Car('Koenigsegg', 'Agera R') self.assertTrue( koenigsegg.is_saloon(), msg='The car type should be saloon if it is not a trailer')
from car_class import Car # импортируем класс Car из отдельного файла car_class.py 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()
# ------- Vehicle Parking System for Kigali Arena ------- # # @Authors : Achille Tanwouo and Samuel Anumudu # Import modules / files import time from moto_class import Moto from car_class import Car from truck_class import Truck from controller import Controller queue = [ ] # Here we wish to create an empty array for queuing vehicles for organizational purposes for i in range(30): if i < 10: queue.append(Moto()) time.sleep(0.05) elif 10 < i < 20: queue.append(Car()) time.sleep(0.05) else: queue.append(Truck()) time.sleep(0.05) # Checking for cars in the queue for vehicle in queue: Controller.control_vehicles(vehicle) print(queue)
def test_car_instance(self): honda = Car('Honda') self.assertIsInstance( honda, Car, msg='The object should be an instance of the `Car` class')
def test_car_wheels(self): man = Car('MAN', 'Truck', 'trailer') koenigsegg = 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_default_car_model(self): gm = Car() self.assertEqual('GM', gm.model, msg="The car's model should be called `GM` if no model was passed as an argument")
def test_default_car_name(self): gm = Car() self.assertEqual( 'General', gm.name, msg='The car should be called `General` if no name was passed as an argument')
print( "Testing Vehicle with Passengers = 4 and Cargo = 6. Expected result: 4, 3") print(vehicle1.n_passengers) print(vehicle1.cargo_size) print( "\nTesting Vehicle with Passengers = 12 and Cargo = 10. Expected result: 12, 10" ) print(vehicle2.n_passengers) print(vehicle2.cargo_size) # create 2 car instances # make car accelerate and make them break # make car honk and park car1 = Car(4, 6, "Isuzu", 25, 250) car2 = Car(12, 10, "Tesla", 84, 150) print("\nTesting Car accelleration") print(car1.accelerate()) print(car2.accelerate()) print("\nTesting Car breaking") print(car1.breaking()) print(car2.breaking()) print("\nTesting Car honking") print(car1.honk()) print(car2.honk()) print("\nTesting Car parking")
from car_class import Car, ElectricCar # импортировани нескольких определенных классов из одного модуля """from car - импортирование всего модуля""" """from car import * - импортирование всех классов из модуля""" my_beetle = Car("volkswagen", "beetle", 2016) print(my_beetle.get_descriptive_name()) my_tesla = ElectricCar("tesla", "roadstep", 2018) print(my_tesla.get_descriptive_name())