责任链模式(python)
2024-10-16 19:54:02
rom abc import ABCMeta, abstractmethod
class Handler(metaclass=ABCMeta):
@abstractmethod
def handle_leave(self,day):
pass
class GeneralManager(Handler):
def handle_leave(self,day):
if day <= 10:
print(f'总经理准假{day}天')
else:
print('不予批准!')
class DepartmentManager(Handler):
def __init__(self):
self.next = GeneralManager()
def handle_leave(self, day):
if day <= 5:
print(f'部门经理准假{day}天')
else:
print('权限不足,请求上级审批!!')
self.next.handle_leave(day)
class ProjectDirector(Handler):
def __init__(self):
self.next = DepartmentManager()
def handle_leave(self, day):
if day <= 3:
print(f'项目主管准假{day}天')
else:
print("权限不足,请求上级审批!!")
self.next.handle_leave(day)
测试:
最新文章
- windows多线程编程星球(一)
- as3正则表达式
- 利用crontab系统每天定时备份MySQL数据库
- Myeclispe 安装 SVN :
- 安装和使用Linux花生壳(公网版)
- 多线程编程4 - NSOperationQueue
- JS-改变页面的颜色(二)
- base.js
- 设计模式C#实现(四)——迭代器模式
- Codeforces Round #339 Div.2 B - Gena&#39;s Code
- 《搭建更新DNS集群服务》RHEL6
- git bash中带空格的文件夹以及文件的处理
- Oracle sequence排序的使用
- linux int to string 方法
- Robot Framework与Web界面自动化测试学习笔记:定位到新窗口
- C++实现动态顺序表
- Andorid自动读取短信验证码
- hdu4614 线段树+二分 插花
- 《程序设计实践》【PDF】下载
- ZOJ3774 Power of Fibonacci 斐波那契、二项式定理
热门文章
- matplotlib animation
- 【C/C++】习题3-7 DNA/算法竞赛入门经典/数组与字符串
- pytest_BDD + allure 自动化测试框架
- Airtest结合tidevice实现IOS自动化测试
- pipeline 结构设计
- 两大js移动端调试神器 / 调试工具分享 !
- Table.SplitColumn拆分…Split…(Power Query 之 M 语言)
- CF1025B Weakened Common Divisor 题解
- cmake之错误【Modules/ExternalProject.cmake:3206 (_ep_add_download_command)....】
- 【九度OJ】题目1177:查找 解题报告