摘要:
set(new offstate()); }}class offstate implements state{ public function show(){ echo '是关灯状态'; } public function handle($light){ $light->set(new ons... 阅读全文
摘要:
"; } public function Method2() { echo "abstract Method2"; } public function Method3() { echo "abstract Method3"; } public function doSomeThing()//骨架... 阅读全文
摘要:
state = $state; } public function getState(){ return $this->state; } public function copy(){ return clone $this;//浅拷贝 /* * 深拷贝 */// $tmp = s... 阅读全文
摘要:
a = new pjl(); } public function say(){ $this->a->say(); } public function ml(){ $this->a->ml(); }}$m = new wangpo();$m->say();echo "";$m->ml();?> ... 阅读全文
摘要:
策略模式是有客户端自行实例化算法类的,而简单工厂模客户端只传参数,不关心对象的生成。结合两种模式,可以在使用策略模式的时候客户端不再生成算法的对象。修改策略模式的配置类即可。在之前策略模式基础上,修改如下cg = new category_a();break; case 'b': $... 阅读全文