3.Write an Employee class that keeps data attributes for the following pieces of information:
a. Employee name
b. Employee number Next, write a class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker class should keep data attributes for the following information:
c. Shift number (an integer, such as1 for morning shift, 2 for evening shift)
d. Hourly pay rate Write the appropriate accessor and mutator methods for each class.
class Employee:
def __init__(self,name,number):
self.name=name
self.number=number
def setName(self,n):
self.name=n
def getName(self):
return self.name
def setNumber(self,num):
self.number=num
def getNumber(self):
return self.number
class ProductionWorker(Employee):
def __init__(self,shift_num,hourly_pay_rate):
self.shift_num=shift_num
self.hourly_pay_rate=hourly_pay_rate
def getShiftNum(self,snum):
self.shift_num=snum
def getShiftNum(self):
return self.shift_num
def setHrPayRate(self,h):
self.hourly_pay_rate=h
def getHrPayRate(self):
return hourly_pay_rate
Comments
Leave a comment