In that file you will find the Person and Employee classes. Here you will comple
ID: 3669087 • Letter: I
Question
In that file you will find the Person and Employee classes.
Here you will complete a subclass Employee of the Person class as defined in the template. A Pet is an Animal that has a name and an owner, the latter of which is a Person object. The constructor for the Pet class has been provided, and you should not in any way modify that method.
For this question you will write two methods of the Pet class:
__repr__ returns a string with just the name and age of an employee
__str__ returns a sentence that includes information about an employee as
shown below.
The following shows the behavior of the implemented class.
>>>x-Company ("ATT", "NAPERVILLE" >>Y Employee ("Ben",45,14000, x) >>>print (y) Ben makes $14000 at ATT in NAPERVILLE Employee (Ben, 45, ATT, 14000)Explanation / Answer
Executable Code
class Company:
def __init__(self, name, place):
self.cname = name
self.cplace = place
def Name(self):
return self.cname + " " + self.cplace
class Employee(Company):
def __init__(self, name, place,age ,salary ):
Company.__init__(self,name,place)
#self.sname = name
self.ssalary = salary
self.sage = age
def GetEmployee(self):
return self.Name() + " makes " + self.ssalary + " at " + self.cname + " in " + self.cplace
x = Company("ATT","NAPERVILLE")
y = Employee("BEN", "ATT", "45","14000")
print(y.GetEmployee())
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.