10. Overriding methods. _ missing member variable


#1

Oops, try again. my_car does not have a model member variable.

Why I keep getting the above message?

class Car(object):
    condition =  "new"
    def __init__(self, model, color, mpg):
        self.mode = model
        self.color = color
        self.mpg = mpg

    def display_car(self):
        print ("This is a %s %s with %s MPG" % (self.model, self.color, self.mpg))

    def drive_car(self):
        self.condition = "used"

class ElectricCar(Car):
    def __init__(self, model, color, mpg, battery_type):
        Car.__init__(self, model, color, mpg)
        self.battery_type = battery_type

    def drive_car(self):
        self.condition = "like new"

my_car = ElectricCar("Lexus", "black", 90, "molten salt")

print (my_car.condition)
my_car.drive_car()
print (my_car.condition)

#2

Ah! It was bc of the typo at line 4. mode

class Car(object):
    condition =  "new"
    def __init__(self, model, color, mpg):
        self.model = model
        self.color = color
        self.mpg = mpg

    def display_car(self):
        print ("This is a %s %s with %s MPG" % (self.model, self.color, self.mpg))

    def drive_car(self):
        self.condition = "used"

class ElectricCar(Car):
    def __init__(self, model, color, mpg, battery_type):
        Car.__init__(self, model, color, mpg)
        self.battery_type = battery_type

    def drive_car(self):
        self.condition = "like new"

my_car = ElectricCar("Lexus", "black", 90, "molten salt")

print (my_car.condition)
my_car.drive_car()
print (my_car.condition)