This Looks Like A Job For


#1



https://www.codecademy.com/courses/python-intermediate-en-WL8e4/2/4?curriculum_id=4f89dab3d788890003000096#


Everything in my code behaves correctly, but I don't quite understand why. I am confused on why I have to have the following:
return super(PartTimeEmployee, self).calculate_wage(hours)

Why won't these two work:
super(Employee.....)
or
.calculate_wage(self, hours)

Any explanation to help me wrap my head around this would be greatly appreciated!


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
    def full_time_wage(self, hours):
        return super(PartTimeEmployee, self).calculate_wage(hours)

milton = PartTimeEmployee("Milton")
print milton.full_time_wage(10)


#2

By using the super() method you inherit all the attributes and functions of the Parent class Employee.


#3

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