This Looks Like a Job For... what's wrong with my code?


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

# Add your code below!
class PartTimeEmployee(Employee):
  def calculate_wage(self, hours):
    return hours*12.00
  def full_time_wage(self,hours):
    return super(PartTimeEmployee,self).calculate_wage(self, hours)
milton = PartTimeEmployee("milton")
print milton.full_time_wage(8) 

what’s wrong with my code?
the console report

Traceback (most recent call last):
  File "python", line 19, in <module>
  File "python", line 16, in full_time_wage
TypeError: calculate_wage() takes exactly 2 arguments (3 given)


The problem is here …

    return super(PartTimeEmployee,self).calculate_wage(self, hours)

The object on which the calculate_wage method is being called is super(PartTimeEmployee,self). You only need to pass one explicit argument to the method within the parentheses. Remove the self argument from the call to calculate_wage. The line should be …

    return super(PartTimeEmployee, self).calculate_wage(hours)


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.