Hi, I am showing part of my code for the ElectricCar class. In the end, I simply redefine my arguments: model, color and mpg again in the ElectricCar class. But isn't ElectricCar already a DerivedClass from my BaseClass?
But again, when I defined my variable my_car, I realised it has to take all my arguments: model, color, mpg, battery_type.
If I defined it as:
----def init(self, battery_type):
---------self.battery_type = battery_type
My variable cannot call the class ElectricCar properly (as ElectricCar takes different number of arguments?)
my_car = ElectricCar("Honda", "blue", 80, "molten salt")
My other alternative tries:
(1) Using the super function does not make sense as I am not replacing some previous definition in my BaseClass
(2) Calling Car.init(self, model, color, mpg) did not work as well
So this is what I did:
class ElectricCar(Car): def __init__(self, model, color, mpg, battery_type): self.battery_type = battery_type self.model = model self.color = color self.mpg = mpg
Please explain to me why? Are there any simpler methods to resolve this?
It seems that the Derivedclass can only inherit the definitons but not my BaseInstance from the BaseClass.
Thanks in advance