7外观模式-代理模式.docVIP

  • 150
  • 0
  • 约1.6千字
  • 约 5页
  • 2017-01-22 发布于重庆
  • 举报
7外观模式-代理模式

14 外观模式 在电脑主机(Mainframe)中,只需要按下主机的开机按钮(on()),即可调用其他硬件设备和软件的启动方法,如内存(Memory)的自检(check()),CPU的运行(run()),硬盘(HardDisk)的读取(read()),操作系统(OS)的载入(load())等,如果某一过程发生错误则电脑启动失败。使用外观模式模拟该过程,绘制类图并编程实现。 package FacadePattern; class Mainframe { ----; ----; ----; ----; public Mainframe() { ----; ----; ----; ----; } public void on() { ----; ----; ----; ----; } public void off() { ----; ----; ----; ----; } } class Memory { public void check() { System.out.println( Memory checking!); } public void off() { System

文档评论(0)

1亿VIP精品文档

相关文档