标签:CPU package 软件设计 pattern 番外 Appearance class public
在计算机主机(Mainframe)中,只需要按下主机的开机按钮(on()),即可调用其他硬件设备和软件的启动方法 ,如内存(Memory)的自检(check())、CPU的运行(run())、硬盘(HardDisk)的读取(read())、操作系统(OS)的载入(load()),如果某一过程发生错误则计算机启动失败。
实验要求:
1. 提交类图;
2. 提交源代码;
package Appearance_pattern;
public class Client
{
public static void main(String[]args) {
MainFrame mainframe = new MainFrame();
mainframe.on();
}
}
package Appearance_pattern;
public class CPU {
public boolean run(){
System.out.println("CPU加载成功");
return true;
}
}
package Appearance_pattern;
public class HardDisk {
public boolean read(){
System.out.println("硬盘读入成功");
return true;
}
}
package Appearance_pattern;
public class MainFrame {
public Memory memory = new Memory();
private CPU cpu = new CPU();
private HardDisk hardDisk = new HardDisk();
private OS os = new OS();
public void on(){
memory.check();
cpu.run();
hardDisk.read();
os.load();
}
}
package Appearance_pattern;
public class Memory {
public boolean check(){
System.out.println("内存检查成功");
return true;
}
}
package Appearance_pattern;
public class OS {
public boolean load(){
System.out.println("操作系统载入成功");
return true;
}
}
3.注意编程规范。
标签:CPU,
package,
软件设计,
pattern,
番外,
Appearance,
class,
public
From: https://www.cnblogs.com/zjsdbk/p/17829945.html