它适用于Employee
and calculate_wage
,但是当我尝试创建 的实例PartTimeEmployee
并调用的父类的calculate_wage
方法时返回错误。PartTimeEmployee
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 __init__(self, employee_name):
self.employee_name = employee_name
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.full_time_wage(10))