14. This Looks Like a Job For


#1



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


Oops, try again. Your code raised an exception, have a look at the console window for the error message!
Traceback (most recent call last):
File "python", line 20, in
NameError: name 'self' is not defined


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).method(x)

milton = PartTimeEmployee("Bob")
print self.hours * 20.00


#2

last line of your code:

print self.hours * 20.00

could you explain why you did this and why here?


#3

problem1.
return super(PartTimeEmployee, self).method(x)
method will be calculate_wage() with hours as parameter!

Problem2.
Last line as Mod mentioned!


#4

I don't know, and for problem 1 it said it was ok in the program. What is wrong with the last line?I don't get it


#5

Hint..

update**
How you call a method ?

If X is instance and Y() is method with z, as argument.

then
X.Y(z)

to print?
print X.Y(z)


#6

So so sorry, but it still displays an error message saying full_time_wage is not defined, when I have clearly defined it. I seriously don't get this :sweat:

milton = PartTimeEmployee("Bob")
print full_time_wage * 10

#7

You created an instance Milton using PartTimeEmployee class right?

milton = PartTimeEmployee("Eric")
Your instance now have access to method ...

full_time_wage


#8

sorry once again, but it still doesn't work

milton = PartTimeEmployee("Bob")
print full_time_wage

#9

if X is instance and Y() is method with z, as argument.

then
X.Y(z)

to print?
print X.Y(z)

Milton is an instance.
full_time_wage is a method ..
can you find the argument that'd go inside the full_time_wage( ? ) method ??


#10

So I've done this so far but my argument is wrong since the error message says "hours" is not defined

print milton.full_time_wage(hours)

#11

you need to specify the number of hours (which is an integer), how many hours did milton work?


#12

Take a look at this snap!!
and yeah as Mod mentioned! :slight_smile:


#13

Honestly, THANKS SO MUCH! I've spent so much time on this and I was getting really impatient but you guys were super patient so thankssss!!!!!:laughing:

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)

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

#14

:slight_smile: Keep up the good work!! :thumbsup:


#15

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