首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件开发 >

设计模式:外观形式

2013-12-13 
设计模式:外观模式2、外观模式的例子?//电脑的部件class CPU {public void processData() { }}class Memory

设计模式:外观模式

2、外观模式的例子


?

//电脑的部件    class CPU {        public void processData() { }    }    class Memory {        public void load() { }    }    class HardDrive {        public void readdata() { }    }    /* 外观 */    class Computer {        private CPU cpu;        private Memory memory;        private HardDrive hardDrive;        public Computer() {            this.cpu = new CPU();            this.memory = new Memory();            this.hardDrive = new HardDrive();        }        public void run() {            cpu.processData();            memory.load();            hardDrive.readdata();        }    }    class User {        public static void main(String[] args) {            Computer computer = new Computer();            computer.run();        }    }

?

热点排行