class Employee:
def init(self, id, name):
self.id = id
self.name = name
def getselary(self, who):
if who.Class == "A":
return who.basic + who.banus - who.offdays*5
if who.Class == "B":
return who.basic + who.salesnum * 0.05
if who.Class == "C":
return who.workhours * 30
class Clerk(Employee):
Class = “A”
def __init__(self, id, name, basic, banus, offdays):
super().__init__(id, name)
self.basic = basic
self.banus = banus
self.offdays = offdays
# def getselary(self):
# return self.basic + self.banus - self.offdays*5
class Saleman(Employee):
Class = “B”
def __init__(self, id, name, basic, salesnum):
super().__init__(id, name)
self.basic = basic
self.salesnum = salesnum
# def getselary(self):
# return self.basic + self.salesnum * 0.05
class HourlyWorker(Employee):
Class = “C”
def __init__(self, id, name, workhours):
super().__init__(id, name)
self.workhours = workhours
# def getselary(self):
# return self.workhours*30
if name == ‘main’:
clerk = Clerk(“01”, “fuhao”, 3000, 2000, 3)
print(clerk.getselary(clerk))