设计模式-外观模式
来源:互联网 发布:南宁关键字优化公司 编辑:程序博客网 时间:2024/06/03 14:25
外观模式(Facade Pattern)
外观模式是软件工程中常用的一种软件设计模式。它为子系统中的一组接口提供一个统一的高层接口。这一接口使得子系统更加容易使用。
外观模式是软件工程中常用的一种软件设计模式。它为子系统中的一组接口提供一个统一的高层接口。这一接口使得子系统更加容易使用。
public class CPU { public void startup(){ System.out.println("cpu startup!"); } public void shutdown(){ System.out.println("cpu shutdown!"); } }
public class Memory { public void startup(){ System.out.println("memory startup!"); } public void shutdown(){ System.out.println("memory shutdown!"); } }
public class Disk { public void startup(){ System.out.println("disk startup!"); } public void shutdown(){ System.out.println("disk shutdown!"); } }
public class Computer { private CPU cpu; private Memory memory; private Disk disk; public Computer(){ cpu = new CPU(); memory = new Memory(); disk = new Disk(); } public void startup(){ System.out.println("start the computer!"); cpu.startup(); memory.startup(); disk.startup(); System.out.println("start computer finished!"); } public void shutdown(){ System.out.println("begin to close the computer!"); cpu.shutdown(); memory.shutdown(); disk.shutdown(); System.out.println("computer closed!"); } }
public class User { public static void main(String[] args) { Computer computer = new Computer(); computer.startup(); computer.shutdown(); } }
start the computer!cpu startup!memory startup!disk startup!start computer finished!begin to close the computer!cpu shutdown!memory shutdown!disk shutdown!computer closed!
0 0
- 设计模式--外观模式
- 设计模式-外观模式
- 设计模式:外观模式
- 设计模式----外观模式
- 设计模式------外观模式
- 设计模式 外观模式
- 设计模式-【外观模式】
- 设计模式-----外观模式
- 设计模式 - 外观模式
- 设计模式 - 外观模式
- 设计模式- 外观模式
- 设计模式-外观模式
- 设计模式 - 外观模式
- 设计模式-外观模式
- 设计模式 - 外观模式
- 设计模式-外观模式
- 设计模式--外观模式
- 设计模式-外观模式
- iOS强弱引用宏
- 手把手教你使用Git--初学者的好福利
- 通往全栈工程师的捷径 —— react
- Masonry教程--IOS自适配
- Web开发&文件上传下载及编码解码
- 设计模式-外观模式
- Terminating app due to uncaught exception unrecognized selector sent to instance程序崩毁后如何快速定位哪一行错误
- Android按菜单键闪退问题
- iOS Newbie - Xcode 7 & iOS 9 Navigation Bar & Status Bar
- 在SharePoint 上配置 Project 2013
- 设计模式-享元模式
- 软件系统开发及Linux概念架构理解
- 字节存储排序:大端和小端的判别及转换
- PullToRefreshListView添加头部需求