程序员类属性姓名、工号、工资、奖金行为工作软件开发测试工程师属性姓名、工号、工资行为工作 软件测试项目经理类属性姓名、工号、工资、奖金行为 工作控制进度使用继承思想实现
class Programmer: def init(self, name, emp_id, salary, bonus): self.name = name self.emp_id = emp_id self.salary = salary self.bonus = bonus
def work(self):
print("I am working on software development.")
class Tester(Programmer): def init(self, name, emp_id, salary): super().init(name, emp_id, salary, 0)
def work(self):
print("I am working on software testing.")
class ProjectManager(Programmer): def init(self, name, emp_id, salary, bonus): super().init(name, emp_id, salary, bonus)
def work(self):
print("I am controlling the project progress."
原文地址: https://www.cveoy.top/t/topic/f31o 著作权归作者所有。请勿转载和采集!