diff --git a/11.FacadePattern/1.Picture/外观模式.png b/11.FacadePattern/1.Picture/外观模式.png new file mode 100644 index 0000000..560b1c3 Binary files /dev/null and b/11.FacadePattern/1.Picture/外观模式.png differ diff --git a/11.FacadePattern/1.Picture/外观模式举例图.png b/11.FacadePattern/1.Picture/外观模式举例图.png new file mode 100644 index 0000000..b2423e1 Binary files /dev/null and b/11.FacadePattern/1.Picture/外观模式举例图.png differ diff --git a/11.FacadePattern/1.Picture/外观模式实例UML图.png b/11.FacadePattern/1.Picture/外观模式实例UML图.png new file mode 100644 index 0000000..337c2c9 Binary files /dev/null and b/11.FacadePattern/1.Picture/外观模式实例UML图.png differ diff --git a/11.FacadePattern/1.Picture/外观模式耦合度图.png b/11.FacadePattern/1.Picture/外观模式耦合度图.png new file mode 100644 index 0000000..97d49d3 Binary files /dev/null and b/11.FacadePattern/1.Picture/外观模式耦合度图.png differ diff --git a/11.FacadePattern/2.Code/FacadePattern.h b/11.FacadePattern/2.Code/FacadePattern.h new file mode 100644 index 0000000..4382b78 --- /dev/null +++ b/11.FacadePattern/2.Code/FacadePattern.h @@ -0,0 +1,69 @@ +#ifndef __FACADE_PATTERN_H__ +#define __FACADE_PATTERN_H__ + +//ϵͳڴ +class Memory +{ +public: + Memory(){} + void selfCheck(){ + printf("ڴԼ졭\n"); + } +}; + +//ϵͳCPU +class CPU +{ +public: + CPU(){} + void run(){ + printf("CPUС\n"); + } +}; + +//ϵͳӲ +class HardDisk +{ +public: + HardDisk(){} + void read(){ + printf("ȡӲ̡\n"); + } +}; + +//ϵͳϵͳ +class OS +{ +public: + OS(){} + void load(){ + printf("ϵͳ\n"); + } +}; + +// +class Facade +{ +public: + Facade(){ + memory = new Memory(); + cpu = new CPU(); + hardDisk = new HardDisk(); + os = new OS(); + } + void powerOn(){ + printf("ڿ\n"); + memory->selfCheck(); + cpu->run(); + hardDisk->read(); + os->load(); + printf("ɣ\n"); + } +private: + Memory *memory; + CPU *cpu; + HardDisk *hardDisk; + OS *os; +}; + +#endif //__FACADE_PATTERN_H__ \ No newline at end of file diff --git a/11.FacadePattern/2.Code/main.cpp b/11.FacadePattern/2.Code/main.cpp new file mode 100644 index 0000000..256b819 --- /dev/null +++ b/11.FacadePattern/2.Code/main.cpp @@ -0,0 +1,13 @@ +#include +#include "FacadePattern.h" + +int main() +{ + Facade *facade = new Facade(); + facade->powerOn(); + + printf("\n\n"); + + system("pause"); + return 0; +} \ No newline at end of file diff --git a/README.md b/README.md index 8b574c1..f4ea97f 100644 --- a/README.md +++ b/README.md @@ -51,4 +51,8 @@ 13.设计模式(十三)——装饰模式 -博客地址:https://blog.csdn.net/sinat_21107433/article/details/102733023 \ No newline at end of file +博客地址:https://blog.csdn.net/sinat_21107433/article/details/102733023 + +14.设计模式(十四)——外观模式 + +博客地址:https://blog.csdn.net/sinat_21107433/article/details/102752643 \ No newline at end of file