您的位置:首页 > 其它

外观模式

2016-06-28 09:41 337 查看
public class CPU{

public void StartUp(){

System.out.println("the cup is startup");

}

public void shutdown(){

System.out.println("the cpu is shutdown");

}

}

public class Memory{

public void StartUp(){

System.out.println("the memeory is startup");

}

public void shutdown(){

System.out.println("the memory is shutdown");

}
}

public class Disk{

public void StartUp(){

System.out.println("the disk is startup");

}

public void shutdown(){

System.out.println("the disk is shutdown");

}
}

public class Computer{

private CPU cpu;

private Memory memory;

private Disk disk;

public Computer(){

cpu = new CPU();

memory = new Memory();

disk = new Disk();

}

public void startup(){

cpu.startup();

memory.startup();

disk.startup();

}

public void shutdown(){

cpu.shutdown();

memory.shutdown();

disk.shutdown();

}

}

public class User{

Computer  computer = new Computer();

computer.startup();

computer.shutdown();

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  外观模式