14/18 This looks like a job for... (STUCK!)


#1



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


Traceback (most recent call last):
File "python", line 11, in
File "python", line 21, in PartTimeEmployee
AttributeError: 'function' object has no attribute 'full_time_wage'


I have been stuck at this exercise for a few days, and I was looking for an answer from the forums for it. Unfortunately all the topics were over one year old, so the exersice is probably updated and the codes from these topics didn't somehow match.


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.00

    def full_time_wage(self, hours):
        return super(PartTimeEmployee, self).calculate_wage(hours)
    
    def milton():    
        milton = PartTimeEmployee("smthng")
    print milton.full_time_wage(10)


#2

You are not to create a function named milton,

but an instance of the employee class named milton and an example of instance declaration looks like this assuming a class is already defined,

example = ExampleClass("Example")
print example.age(10)

#3

Oh, thank you! I declared the milton as a variable instead of defining it, but after a few testing I'm stuck again. :confused:

Now my class looks like this:

class PartTimeEmployee(Employee):
def calculate_wage(self, hours):
self.hours = hours
return hours * 12.00

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

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

Now the system simply says, that I didn't create an instance of the PartTimeEmployee class called milton.
The output is right, (200.0$) and I don't know the reason for this error.

Sorry for a late post by the way.


#4

Boahaha I'm too stupid... I was calling the variable milton inside the class.

Thanks for your help, anyway!!


#5

The code below just worked for me:
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 * 10.00

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

milton = PartTimeEmployee("joseph")
print milton.calculate_wage(20)


#6

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

PartTimeEmployee.calculate_wage
milton = PartTimeEmployee("jay")
print milton.ful_time_wage(10)

This is the error!!!!!! i dont understand please help

Oops, try again. full_time_wage seems to be missing from PartTimeEmployee!


#7

PartTimeEmployee.calculate_wage
milton = PartTimeEmployee("jay")
print milton.ful_time_wage(10)

check your spelling!


#8

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