14. This looks like a job for


#1

I know here are a lot of posts already but I still cannot figure out what is wrong here... This is the error message:
I appreciate every help

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

# Add your code below!
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("Peter")
print milton.full_time_wage(10)

#2

I know what the problem and hence, the solution is but why does calculate_wage only need hours as an argument?


#3

The second calculate_wage only takes one argument which is hours. Because you are not adding a method you don't need the self.


#4

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):
        self.hours=hours
        return hours*12.00
    def full_time_wage(self, hours):
        return super(PartTimeEmployee, self).calculate_wage(hours)
    
milton=PartTimeEmployee("Steven")
print milton.full_time_wage(10)

This worked for me. For some reason (not explained in the instructions, and therefore non-comprehensive) in the "super" command the base-class method "m()" does not require "self". I got the solution by accident while experimenting. Could someone please explain why "m()" doesn't need self as argument?
-Thank you


#5

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