外观模式/ 门面模式(Facade Pattern)
来源:互联网 发布:资源均衡优化的步骤 编辑:程序博客网 时间:2024/04/29 16:03
百度词条的解释
http://baike.baidu.com/view/2739662.htm
<?php//正面模式(外观模式)//外观类(厨师)class Cook {private $foods = array();//烹饪public function cooking(Customer $customer) {$menuList = $customer->getOrder();foreach($menuList as $value) {switch($value){case 'pig':$menu = new Pig();break;case 'vegetable':$menu = new Vegetable();break;case 'fish':$menu = new Fish;break;}$cookingFood = $menu->cooking();array_push($this->foods,$cookingFood);}}public function getFoods(){return $this->foods;}}//顾客类class Customer {private $menu = array();public function order($food) {array_push($this->menu,$food);return $this;}public function getOrder() {return $this->menu;}}class Pig {public function cooking() {return 'ripe-pig';}}class Vegetable {public function cooking() {return 'ripe-vegetable';}}class Fish {public function cooking() {return 'ripe-fish';}}//顾客类实例$custom = new Customer();$custom->order('fish')->order('pig')->order('vegetable');//厨师类实例(外观类实例)$cook = new Cook();$cook->cooking($custom);var_dump($cook->getFoods());?>
- 外观模式/ 门面模式(Facade Pattern)
- facade pattern--门面模式或外观模式
- 门面模式(Facade pattern)
- 门面模式【FACADE PATTERN 】
- 门面模式(Facade Pattern)
- Facade Pattern 门面模式
- 门面模式【Facade Pattern】
- 门面模式【Facade Pattern】
- 外观模式(Facade Pattern)或门面模式
- 门面模式(外观Facade模式)
- 外观模式(门面模式)--Facade
- Facade 外观(门面)模式
- 外观/门面模式(Facade)
- 外观模式(Facade Pattern)
- 外观模式(Facade Pattern)
- 外观模式 Facade Pattern
- 外观模式(Facade Pattern)
- 外观模式(Facade Pattern)
- MySql 常用Sql语句
- 享元模式(Flyweight Pattern)
- 原型模式(Prototype Pattern)
- qt 拖动子窗体,父窗体同时移动
- 让DOS显示中文
- 外观模式/ 门面模式(Facade Pattern)
- Dynamics CRM 2011 表单Debug常用命令
- 职责链模式(Chain of Responsibility Pattern)
- 中介者模式(调停者模式)
- C++之多态性
- android文本组件textView属性autolink设置为web,显示网址的处理方法
- JNI回调函数
- WWDC2012 谁是赢家谁是输家?
- 逐字符串