11 2015 档案
摘要:_mediator = $mediator; } public function send($message) { $this->_mediator->send($message,$this); } abstract public function not...
阅读全文
摘要:0; } //一旦科技建筑造好了或者被摧毁,调用这个方法,参数$techBuildingName代表建筑名称 //$add为布尔值,true表示增加(建造),false代表减少(摧毁) public static function changeTech ($techBuil...
阅读全文
摘要:imp->operationImp(); }}// 修正抽象化角色, 扩展抽象化角色,改变和修正父类对抽象化的定义--具体画图类class RefinedAbstraction extends Abstraction{ public function __construct(Implem...
阅读全文
摘要:imp = $imp;//$this->imp接收的是一个实例化后的Implementor接口下的具体对象 } //部队的钻地方法,可以扩展基本对象的钻地 public function underground() { $this->imp->undergrou...
阅读全文
摘要:参考资料: http://www.jb51.net/article/27473.htm_title = $title; } public function getTitle() { return $this->_title; } public funct...
阅读全文
摘要:_intrinsicState = $state; } public function operation($state) { echo $state; }}// 不共享的具体享元,客户端直接调用class UnsharedConcreteFlyweight e...
阅读全文
摘要:当显示机枪兵状态时,绘制工厂会判断机枪兵实例是否已经存在了如果存在了就直接返回//如果把static private $flyweights;//改为private $flyweights;//对应的self::改成$this为什么不行呢???getFlyweight("Marine");//绘制一...
阅读全文
摘要:'; } // some more function below // ...}//这是一个文印处理店,只文印,卖纸,不照相class TextShop{ private $printer; public function __construct(Printer $pr...
阅读全文
摘要:builder = $builder; } //负责建造流程的方法,调用建造器对象的方法,制造所有零件 public function buildeAllPart() { //制造地图零件 $this->builder->buildMapPart(...
阅读全文
摘要:_type = $type; } //建造产品的价格 public function setPrice($price) { echo 'set the price of the product,'; $this->_price = $price; ...
阅读全文
摘要:* @package design pattern * @version v1.0 2011-12-14 *//*产品角色-在指导者的指导下由建造者所创建的那个复杂的对象*/class Person{ private $head; private $body; p...
阅读全文
摘要:用途总结:模板模式可以将一系列的步骤自动化,同时又可以满足不同的细节变化。实现总结:需要一个抽象类来包含框架函数,让具体的子类继承它,并实现所有的步骤。使用的时候只要调用框架函数就自动完成了。比如:再来一个 “地刺”的演化,只需要写一个class diceEvolution extends evol...
阅读全文
摘要:"; } public function Method2() { echo "abstract Method2"; } public function Method3() { echo "abstract Method3"; } ...
阅读全文
摘要:"; }}//类适配器角色class Adapter implements Target { private $adaptee; function __construct(Adaptee $adaptee) { $this->adaptee = $adapte...
阅读全文
摘要:burrow=new Burrow(); } //钻地的方法 public function burrowOperation() { $this->burrow->burrowOperation();//!!!这里是关键点,调用钻地属性存放的对象,使用钻地类的方...
阅读全文
摘要:迭代器模式最重要的作用:迭代器模式提供一种方法顺序访问一个聚合对象中各个元素,而又不需要暴露该方法中的内部表示。对于集合内部结果常常变化各异,我们不想暴露其内部结构的话,但又想让客户代码透明底访问其中的元素,这种情况下我们可以使用迭代器模式。 迭代器就是把不同的数据结构 "相同功能 "的函数装到...
阅读全文
摘要:aggre = $_aggre; } //返回第一个 public function First() { return $this->aggre[0]; } //返回下一个 public function Next() { ...
阅读全文
摘要:getStatus() );//打印状态$cheatInstance1->setStatus('operation cwal');//输入秘籍var_dump( $cheatInstance1->getStatus() );//打印状态$cheatInstance2 = new cheat();//...
阅读全文
摘要:"; } public static function getInstance() { // 通过此静态方法才能获取本类的对象 if( is_null(self::$obj) ) //如果本类中的$obj为空,说明还没有被实例化过 { ...
阅读全文
摘要:getCreator('enemy');//让具体工厂对象生产鼠标对象$product1 = $realCreator1->creatProduct('Mouse');//让鼠标对象显示颜色,显示结果redecho $product1->color;echo "";//根据归属,得到另一个具体工厂对...
阅读全文
摘要:$canshu["what"](); }}//一个建造实例$begin = new makeshibing();$canshu = array( "who" => "huoyan" , "what" => "make" ,);$how = $begin->zuosa($ca...
阅读全文
摘要:$canshu["what"](); }}//一个建造实例$begin = new makeshibing();$canshu = array( "who" => "huoyan" , "what" => "make" ,);$how = $begin->zuosa($ca...
阅读全文
摘要:make($who);$how->make();//第二期增加坦克兵$begin = new makeshibing();$who = 'tanke';$how = $begin->make($who);$how->make();?>
阅读全文
摘要:getFactory('silver');//让工厂制造一个推荐产品$product = $factory->create('Commendatory');//可以看到是白银会员的推荐商品echo $product->descri;?>
阅读全文
摘要:createBTObject(); }}//获取bt工厂$btFactory = new BtFactory();//BT种子的下载处理$what = 'BTdown';$btObject = $btFactory->getBtObject($what);$btObject->process(...
阅读全文
摘要://---------------------------------------------------//进去参数(类名),出来直接就是对象,没有其他的步骤//电影介绍的处理类class MovieViews{ public function getTimes() { ...
阅读全文
摘要:$value ) { print " $key >>> $value \n" ; } }}$class = new MyClass ();foreach( $class as $key => $value ) { p...
阅读全文
摘要:var = $array ; } } //返回到迭代器的第一个元素 public function rewind () { echo "rewinding返回到迭代器的第一个元素\n" ; reset ( $this -> ...
阅读全文
摘要:"; if(isset($this->$property_name)) { return($this->$property_name); } else { return 220; ...
阅读全文
摘要:./index.php----------------------------------------------------------------------------------./myClass.php--------------------------------------------...
阅读全文
摘要:31) { throw new Exception('月数不能大于31'); } return 1/$x;}try{ echo inverse(5) . ""; echo inverse(10) . ""; echo inverse(2) . ""; ...
阅读全文
摘要:blood = $enemy->blood -self::$kill_hard; } //静态函数 升级 static function up_kill_hard() { self::$kill_hard+=2; } //析构函数 funct...
阅读全文
摘要:"; } function didanggongji() { //建筑飞行的代码 echo "抵挡攻击"; }}//兵营类class marineBuilding extends building{ function createMarine...
阅读全文
摘要:yii\di\Containeryii\base\Componentyii\base\Objectyii\base\Configurableyii\web\Applicationyii\base\Applicationyii\base\Moduleyii\di\ServiceLocatoryii\w...
阅读全文

浙公网安备 33010602011771号