标签:
这是一个抽象的示例。一个客户“you”通过外观接口“computer”获取计算机内部复杂的系统信息。
/* Complex parts */ class CPU { public void freeze() { ... } public void jump(long position) { ... } public void execute() { ... }} class Memory { public void load(long position, byte[] data) { ... }} class HardDrive { public byte[] read(long lba, int size) { ... }} /* Façade */ class Computer { public void startComputer() { cpu.freeze(); memory.load(BOOT_ADDRESS, hardDrive.read(BOOT_SECTOR, SECTOR_SIZE)); cpu.jump(BOOT_ADDRESS); cpu.execute(); }} /* Client */ class You { public static void main(String[] args) { Computer facade = new Computer(); facade.startComputer(); }}
标签:
原文地址:http://www.cnblogs.com/ttylinux/p/4579842.html