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