DesignPattern/14.ChainOfResponsibility/2.Code/main.cpp

51 lines
1.1 KiB
C++
Raw Normal View History

2019-10-29 14:14:19 +00:00
#include <iostream>
#include "ChainOfResponsibility.h"
int main()
{
2021-10-28 15:15:51 +00:00
// 请求处理者:组长,兵哥,春总,老板
2019-10-29 14:14:19 +00:00
Approver *zuzhang, *bingge, *chunzong, *laoban;
2021-10-28 15:15:51 +00:00
zuzhang = new GroupLeader("孙大哥");
bingge = new Head("兵哥");
chunzong = new Manager("春总");
laoban = new Boss("张老板");
2019-10-29 14:14:19 +00:00
zuzhang->setSuperior(bingge);
bingge->setSuperior(chunzong);
chunzong->setSuperior(laoban);
2021-10-28 15:15:51 +00:00
// 创建报销单
2019-10-29 14:14:19 +00:00
Bill *bill1 = new Bill(1, "Jungle", 8);
Bill *bill2 = new Bill(2, "Lucy", 14.4);
Bill *bill3 = new Bill(3, "Jack", 32.9);
Bill *bill4 = new Bill(4, "Tom", 89);
2021-10-28 15:15:51 +00:00
// 全部先交给组长审批
2019-10-29 14:14:19 +00:00
zuzhang->handleRequest(bill1); printf("\n");
zuzhang->handleRequest(bill2); printf("\n");
zuzhang->handleRequest(bill3); printf("\n");
zuzhang->handleRequest(bill4);
printf("\n\n");
2020-11-29 05:40:29 +00:00
delete zuzhang;
delete bingge;
delete chunzong;
delete laoban;
delete bill1;
delete bill2;
delete bill3;
delete bill4;
2022-03-09 15:09:06 +00:00
zuzhang = nullptr;
bingge = nullptr;
chunzong = nullptr;
laoban = nullptr;
bill1 = nullptr;
bill2 = nullptr;
bill3 = nullptr;
bill4 = nullptr;
2020-11-29 05:40:29 +00:00
2019-10-29 14:14:19 +00:00
system("pause");
return 0;
}