Inheritance


#1

I think I am not able to follow instruction or Im missing something clue.
Parent Class Car has member variable of model, color, mpg and now we created Electric Car which is a derived class or we must say a child class. We derived Electric Car class because we don't have battery_type on Parent Class, i think that is the mission there to be accomplish. I have check my code in pycharm seems ok. Any Clue for this member variable?


#2

well, __init__() of ElectricCar will overwrite init of Car, so you will have to initialize all member variable again


#3

I think I am stuck now. or i think don't know much in inheritance..
I have 2 code that doesn't work.

this is using super()

and the other is re initialize


#4

Please copy paste your code to the forum so i can run it, use format:

So indent shows

as for your first approach, this is python2, so you can't call super() without arguments


#5

Thanks it is my mistake for typos.

the requirements need to be the same class name what the instruction mention.
I have used EletricCar, instead of ElectricCar.

:wink:


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.