php原型模式的研究
2014-03-20 18:14
513 查看
<?php class Sea{} class EarthSea extends Sea{} class MarsSea extends Sea{} class Plains{} class EarthPlains{} class MarsPlains{} class Forest{} class EarthForest{} class MarsForest{} class TerrainFactory{ private $sea; private $forest; private $plains; function __construct(Sea $sea,Plains $plains,Forest $forest){ $this->sea = $sea; $this->plains = $plains; $this->forest = $forest; } function getSea(){ return clone $this->sea; } function getPlains(){ return clone $this->plains; } function getForest(){ return clone $this->forest; } } $factory = new TerrainFactory(new EarthSea,new EarthPlains, new EarthForest); print_r($factory->getSea()); print_r($factory->getPlains()); print_r($factory->getForest()); $mars_factory = new TerrainFactory(new MarsSea,new MarsPlains, new MarsForest); print_r($mars_factory->getSea()); print_r($mars_factory->getPlains()); print_r($mars_factory->getForest());
相关文章推荐
- PHP 设计模式之原型模式
- php 原型模式
- php设计模式 原型模式
- PHP设计模式之原型设计模式原理与用法分析
- php实现设计模式之 原型模式
- php设计模式学习系列(七)--原型对象
- php设计模式-原型模式(Prototype)
- PHP 原型模式
- PHP Prototype(原型)模式
- 初识PHP设计模式--原型模式
- javascript原型模式实现OOP的再研究
- php面向对象开发之——原型模式
- Constructor Prototype Pattern 原型模式(PHP示例)
- PHP设计模式之原型模式定义与用法详解
- PHP设计模式 原型模式(Prototype)
- php单例模式的研究
- 慕课网----大话PHP设计模式 五(原型模式,装饰器模式,迭代器模式,代理模式)
- PHP设计模式之原型模式详解
- [转载]PHP设计模式之:原型模式
- PHP 原型模式