Hey! I have been having a trouble with my code. If anyone can help that would be awesome!
class Employee(object):
"""Models real-life employees!"""
def __init__(self, employee_name):
self.employee_name = employee_name
def calculate_wage(self, hours):
self.hours = hours
return hours * 20.00
class PartTimeEmployee(Employee):
def calculate_wage(self, hours):
return hours * 12.00
def full_time_wage(self, hours):
return super(PartTimeEmployee, self).calculate_wage()
milton = PartTimeEmployee("Milton")
print milton.full_time_wage(10)
volvox
November 20, 2015, 12:01am
2
Hi @pixel_craft554 ,
The calculate_wage
method needs to take an argument for hours
. But you have …
return super(PartTimeEmployee, self).calculate_wage()
In fact, to conform to the instructions from the earlier exercises, you should have this …
class PartTimeEmployee(Employee):
def calculate_wage(self, hours):
self.hours = hours
return self.hours * 12.00
def full_time_wage(self, hours):
self.hours = hours
return super(PartTimeEmployee, self).calculate_wage(self.hours)
Note that the above has …
self.hours = hours
… in both methods
1 Like
I seem to have the code you suggested but it won’t work correctly. It gives me the error message “Oops, try again. milton.full_time_wage(0) returned 200.0 instead of the correct value: 0”
class PartTimeEmployee(Employee):
def calculate_wage(self, hours):
self.hours = hours
return hours * 12.00
def full_time_wage(self, hours):
return super(PartTimeEmployee, self).calculate_wage(self.hours)
milton = PartTimeEmployee(“Milton”)
print milton.calculate_wage(10)
if I use hours instead of self.hours as an argument in calculate_wage it goes through fine but the result for 10 hours is 120 when it is supposed to be 200
1 Like
llx2
December 10, 2015, 5:43pm
5
change this:return super(PartTimeEmployee, self).calculate_wage(self.hours)
to:
return super(PartTimeEmployee, self).calculate_wage(hours)
That should do the trick
In the original method “calculate_wage” requires two arguments (self, hours). Why is only one argument required when using the super call?