Classes 14/18


#1

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
        hours *= 12.00  
        return hours # here partoftime overrides empolyee
    def full_time_wage(self,hours):
        return super(PartTimeEmployee, self).full_time_wage(hours)
milton = PartTimeEmployee("yossef")
milton.full_time_wage(10)

what is the wrong here please help sometime here some times i use the attritubes and it work and sometimes it doesnt could somebody explain to me please
error:
Traceback (most recent call last):
File "python", line 19, in
File "python", line 17, in full_time_wage
AttributeError: 'super' object has no attribute 'full_time_wage'


#2

Problem is here:

def full_time_wage(self,hours):
   return super(PartTimeEmployee, self).full_time_wage(hours)

By super(PartTimeEmployee, self) you are refering to the Employee class:

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

And this class does not have full_time_wage method defined. What you want to do is:

def full_time_wage(self,hours):
   return super(PartTimeEmployee, self).calculate_wage(hours)

#3

yes thanks i just realized this now thanks very much for quick reply


#4

You're very welcome :slight_smile:


#5

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