Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from abc import ABC, abstractmethod
- import copy
- class Car(ABC):
- @abstractmethod
- def clone(self):
- pass
- @abstractmethod
- def specifications(self):
- pass
- class ElectricCar(Car):
- def __init__(self, model, battery_capacity):
- self.model = model
- self.battery_capacity = battery_capacity
- def clone(self):
- return copy.deepcopy(self)
- def specifications(self):
- return f"ElectricCar(model={self.model}, battery_capacity={self.battery_capacity}kWh)"
- class GasolineCar(Car):
- def __init__(self, model, engine_capacity):
- self.model = model
- self.engine_capacity = engine_capacity
- def clone(self):
- return copy.deepcopy(self)
- def specifications(self):
- return f"GasolineCar(model={self.model}, engine_capacity={self.engine_capacity}L)"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement