时间:2021-07-01 10:21:17 帮助过:5人阅读
' ; } } //(2) pc 机器 class Pcmachine { public function turnOn() {} public function turnOff() { echo 'turn off PcMathion
' ; } } // (3) 关闭电源 class Power { public function turnOn() {} public function turnOff() { echo 'turn off Power
' ; } } // 关机的门面角色 class PcFacade implements Facade{ private $PcLight ; private $Pcmachine ; private $Power ; public function __construct(){ $this->PcLight = new PcLight(); $this->Pcmachine = new Pcmachine(); $this->Power = new Power(); } // 门面角色的应用 public function turnOff() { $this->PcLight ->turnOff(); $this->Pcmachine ->turnOff(); $this->Power ->turnOff(); } public function turnOn() {} } // 应用 $button = new PcFacade(); $button ->turnOff(); /* 其实门面模式就是把几个子系统(实例或者类.统一一个统一的接口进行执行,客户端不用关注子系统,只用门面即可 )
http://www.bkjia.com/PHPjc/962642.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/962642.htmlTechArticlephp中的设计模式之--门面模式 ;} }//(2) pc 机器class Pcmachine { public function turnOn() {} public function turnOff() {echo turn off PcMathion ;}}// (3) 关闭电源cla...