装饰器模式,装饰模式装饰器模式
_weapon = $weapon; } public function cost(){ return $this->_weapon->cost() + $this->_price; } public function descriptions(){ return $this->_weapon->descriptions().$this->_descriptions; }}//力量属性class strength extends property{ protected $_price = 30; protected $_descriptions = '+ strength';}//敏捷属性class agility extends property{ protected $_price = 50; protected $_descriptions = '+ agility';}//智力属性class intellect extends property{ protected $_price = 20; protected $_descriptions = '+ intellect';}$weapon = new agility(new strength(new strength(new glave())));echo $weapon->cost();echo $weapon->descriptions();
http://www.bkjia.com/phpjc/983244.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/983244.htmltecharticle装饰器模式,装饰模式 装饰器模式 ? php // 装饰器模式-在不改变原有类的结构上,对类的功能那个作补充//武器基类 abstract class weapon{ abst...