Overriding methods drive_car() problem


#1



Hey all. Can You please help me? I got stuck with an error i cant understand.

Traceback (most recent call last):
File "python", line 20, in
TypeError: drive_car() takes no arguments (1 given)

As You can see i didnt give any arguments into drive_car()
Please help


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"

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.condition="like new"
my_car=ElectricCar("BMW", "GREEN", 999, "molten salt")
print my_car.condition
my_car.drive_car()
print my_car.condition


Overriding Methods - What is Wrong?
#2

@javablaster92540,

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"