this is the task:
First, inside your PartTimeEmployee class:
Add a new method called full_time_wage with the arguments self and hours.
That method should return the result of a super call to the calculate_wage method of PartTimeEmployee’s parent class. Use the example above for help.
Then, after your class:
Create an instance of the PartTimeEmployee class called milton. Don’t forget to give it a name.
Finally, print out the result of calling his full_time_wage method. You should see his wage printed out at $20.00 per hour! (That is, for 10 hours, the result should be 200.00.)
so this is my code
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(self, hours) Milton = PartTimeEmployee("Milton") print full_time_wage(Milton, 10)
actually I check the Hint and I see this:
You super call should look something like this:
def full_time_wage(self, hours):
return super(PartTimeEmployee, self).method(args)
Where method is the method you want (calculate_wage) and args are the arguments that method takes.
so I supposed that the first part of the excersise I did correctly:
but then I get this error:
Traceback (most recent call last):
File “python”, line 19, in
NameError: name ‘full_time_wage’ is not defined
python:1: SyntaxWarning: import * only allowed at module level
So I suppose that the error is actually in this part:
Milton = PartTimeEmployee(“Milton”)
print full_time_wage(Milton, 10)
but I don’t understand my error
thank you very much for your help