它適用於Employee
和calculate_wage
,但在嘗試創建PartTimeEmployee
的實例並調用PartTimeEmployee
的父類的calculate_wage
方法時返回錯誤。爲什麼下面的代碼導致錯誤?
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))
「但返回錯誤」...唉,錯誤消息似乎是一個祕密.... – glglgl
你能請我選擇我的答案是正確的嗎? –