We help IT Professionals succeed at work.

Sample Override Code

Trying to go though some of the python coding on codeacademy.com
http://www.codecademy.com/courses/python-intermediate-en-WL8e4/2/4?curriculum_id=4f89dab3d788890003000096#

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(10.00)
milton = PartTimeEmployee("milton")    

Open in new window

When i try to see where the above code takes me, i get

"Oops, try again. milton.full_time_wage(0) returned 200.0 instead of the correct value: 0    " and I'm stuck.
How do i get to 200.00?
Comment
Watch Question

Author

Commented:
OR how do i format a print statement to print the return of
     super(PartTimeEmployee, self).calculate_wage(10.00)   ?
Your main problem is that you hard-coded a 10.00 in your call to full_time_wage class.  You should be passing in hours.
def full_time_wage(self, hours):
    return super(PartTimeEmployee, self).calculate_wage(hours)

Open in new window


So no matter what you pass into it, you're going to get 200 back.  The system is complaining that when testing your code It passed a 0 in and got back 200 when it should have got 0 back.
A print statement:
milton = PartTimeEmployee('milton')
print(milton.full_time_wage(10))

Open in new window

Author

Commented:
Thanx.  The results print out as expected, but I still get the "Oops, try again. milton.full_time_wage(0) returned 200.0 instead of the correct value: 0" and the codeclinic sends me back to correct?????

Author

Commented:
Sorry clockwatcher.  I missed your 'main' point?.  Everything's ok.  Thanks again.