.编写一个简单的工资管理程序,系统可以管理以下四类人:工人(worker)、销售员(salesman)、经理(manager)、销售经理(salemanger)。 # 所有的员工都具有员工号,姓名,工

class Employee:
    def __init__(self,id,name):
        self.id = id
        self.name = name
        # self.salary = salary

    def set_name(self):
        return self.name

    def get_name(self):
        return self.name

    def get_id(self):
        return self.id


class Worker(Employee):
    def __init__(self,id,name):
        super().__init__(id,name)
        self.monthly = 0
        self.work_hours = 0
        self.hourly_pay = 0

    def works(self,x):
        self.work_hours = x
        return self.work_hours

    def hourp(self,y):
        self.hourly_pay = y
        return self.hourly_pay

    def payroll(self):
        self.monthly = self.work_hours * self.hourly_pay
        return self.monthly


w1 = Worker(1,'yyf')
w1.works(50)
w1.hourp(50)
print(w1.payroll())


class Salesman(Employee):
    def __init__(self, id , name):                      # 初始化对象
        super().__init__(id, name)
        self.monthly1 = 0
        self.sales = 0
        self.deduct = 0

    def smsales(self,value):                        # 销售额传值方法
        self.sales = value
        return self.sales

    def smdeduct(self,value1):                      # 提成传值
        self.deduct = value1
        return self.deduct

    def sm_monthly1(self):                      # 计算月薪
        self.monthly1 = self.sales * self.deduct
        return self.monthly1


m1 = Salesman(1,'yyf')        # 实例化对象
m1.smsales(50000)               # 销售额传值
m1.smdeduct(0.5)                 # 提成传值
print(m1.sm_monthly1())

class Manager(Employee):
    def __init__(self,id,name):
        super().__init__(id,name)
        self.salary = 0

    def m_salary(self,i):
        self.salary = i
        return self.salary

m2 = Manager(3,'yyf')
print(m2.name)
print(m2.m_salary(5000))

你可能感兴趣的:(.编写一个简单的工资管理程序,系统可以管理以下四类人:工人(worker)、销售员(salesman)、经理(manager)、销售经理(salemanger)。 # 所有的员工都具有员工号,姓名,工)