Advertisement

Python每日实践:面向对象的高级练习(day~9)

阅读量:

工资结算系统

复制代码
    from abc import ABCMeta,abstractmethod
    """
    某公司有三种类型的员工 分别是部门经理、程序员和销售员
    需要设计一个工资结算系统 根据提供的员工信息来计算月薪
    部门经理的月薪是每月固定15000元
    程序员的月薪按本月工作时间计算 每小时150元
    销售员的月薪是1200元的底薪加上销售额5%的提成
    """
    class Employee(object,metaclass=ABCMeta):
    def __init__(self,name):
        self._name = name
    
    @property
    def name(self):
        return self._name
    
    @abstractmethod
    def get_salary(self):
        pass
    
    class Manager(Employee):
    
    def get_salary(self):
        return 30000.0
    
    class Programmer(Employee):
    
    def __init__(self,na

全部评论 (0)

还没有任何评论哟~