实验12:外观模式
本次实验属于模仿型实验,通过本次实验学生将掌握以下内容:
1、理解外观模式的动机,掌握该模式的结构;
2、能够利用外观模式解决实际问题。
Client:
package tutorial12;
public class Client {
public static void main(String[] args) {
// TODO 自动生成的方法存根
Mainframe mainframe=new Mainframe();
mainframe.show();
}
}
CPU:
package tutorial12;
public class CPU {
public void run() {
System.out.println("CPU开始启动.....");
System.out.println("CPU正常运行\n");
}
}
HardDisk:
package tutorial12;
public class HardDisk {
public void read() {
System.out.println("HardDisk开始启动.....");
System.out.println("HardDisk正常运行\n");
}
}
Mainframe:
package tutorial12;
public class Mainframe {
private CPU cpu;
private Memory memory;
private OS os;
private HardDisk hardDisk;
public Mainframe() {
memory = new Memory();
cpu = new CPU();
os = new OS();
hardDisk = new HardDisk();
}
public void show() {
cpu.run();
memory.check();
hardDisk.read();
os.load();
}
}
Memory:
package tutorial12;
public class Memory {
public void check() {
System.out.println("Memory开始启动.....");
System.out.println("Memory正常运行\n");
}
}
OS:
package tutorial12;
public class OS {
public void load() {
System.out.println("OS开始启动.....");
System.out.println("OS正常运行\n");
}
}
标签:总结,tutorial12,每日,System,Memory,println,public,out From: https://www.cnblogs.com/jm56/p/17828416.html