快捷搜索:  as  2018  FtCWSyGV  С˵  test  xxx  Ψһ  w3viyKQx

和记娱h88_机器人论坛



// 电源

public class Power {和记娱h88

public void connect() {

System.out.println("The power is connected.");

}

public void disconnect() {

System.out.println("The power is disconnected.");

}

}

// 主板

public class MainBoard {

public void o和记娱h88n() {

System.out.print和记娱h88l和记娱h88n("The mainboard is on.");

}

public void off() {

System.out.println("The mainboard is off.");

}

}

// 硬盘

public class HardDisk {

public void run() {

System.out.println("The harddisk is running.");

}

public void stop() {

System.out.println("The harddisk is stopped.");

}

}

// 操作系统

public class OperationSystem {

public void startup() {

System.out.println("The opertion system is startup.");

}

public void shutdown() {

System.out.println("The operation system is shutdown.");

}

}

// 谋略机外不雅

public class Computer {

private Power power;

private MainBoard board;

private HardDisk disk;

private OperationSystem system;

public Computer(Power power, MainBoard board, HardDisk disk, OperationSystem system) {

this.power = power;

this.board = board;

this.disk = disk;

this.system = system;

}

public void startup() {

this.power.connect();

this.board.on();

this.disk.run();

this.system.startup();

}

public void shutdown() {

this.system.shutdown();

this.disk.stop();

this.board.off();

this.power.disconnect();

}

}

这个是测试法度榜样:

// 测试谋略机外不雅类

public class TestComputer {

public static void main(String[] args) {

Power power = new Power();

MainB和记娱h88oard board = new MainBoard();

HardDisk disk = new HardDisk();

OperationSystem system = new OperationSystem();

Computer computer = new Computer(power, board, disk, system);

computer.startup();

computer.shutdown();

}

}

测试结果:

引用

您可能还会对下面的文章感兴趣: