10. overriding methods


#1




HELP, it shows me this error : Oops, try again. It looks like you didn't update the condition of my_car to 'like new'.


class Car(object):
    condition = "new"
    def __init__(self, model, color, mpg):
        self.model = model
        self.color = color
        self.mpg   = mpg
        
    def display_car(self):
        return 'This is a %s %s with %s MPG.' %(self.color, self.model, str(self.mpg))
        
    def drive_car(self):
        self.condition = 'used'

my_car = Car("DeLorean", "silver", 88)

print my_car.condition

my_car.drive_car()

print my_car.condition

class ElectricCar(Car):
    def __init__(self, model, color, mpg, battery_type):
        self.model = model
        self.color = color
        self.mpg = mpg
        self.battery_type = battery_type
        
my_car = ElectricCar('DeLorean', 'black', 88, 'molten salt')


#2

your ElectricCar class:

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

then step 1 of the instructions:
Inside ElectricCar add a new method drive_car() that changes the car's condition to the string "like new"

i don't see the new drive_car() method inside ElectricCar class?

then print the condition of your Electric car (my_car object), then take it for a drive, then print the condition again (all this for the Electric car, not the non-electric car)


#3

thank you, really, i didn't read the explanation well :zipper_mouth:


#4