14 ex. I've done it, but I can't understand


I can't understand why milton.full_time_wage(10) is returning 200, (it's correct) instead of 20*12 (too lazy to check)

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(hours)

milton = PartTimeEmployee("milton")
print Bob.calculate_wage(21)

print milton.full_time_wage(10)


This line is a call to the full_time_wage method of the PartTimeEmployee instance, but that method defers to the super class method, calculate_wage.

10 * 20 == 200


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