this is my homework assignment, I saw it posted on the website before, but it looks like it was unsolved and I got a different error message than a person asking that questi
The error is pretty clear. salary
is not defined in the __init__
method of Executive
.
You used wage
as an argument to __init__
, but salary
when calling __init__
of your parent class, so you should stick to one variable name:
class Executive(Employee):
def __init__(self, name, salary, yearlyBonus):
Employee.__init__(self, name, salary)
Also, you can get around typing all of those parameters in each time by using *args
:
class Executive(Employee):
def __init__(self, *args, yearlyBonus):
super(Executive, self).__init__(*args)
Use super()
instead of calling the parent class's __init__
method. It makes multiple inheritance a bit easier.