失落空间
条新通知
登录
注册
欢迎
退出
我的博客
配置
写文章
文章管理
博客首页
全站
当前博客
空间
博客
好友
相册
留言
用户操作
[留言]
[发消息]
[加为好友]
订阅我的博客
[编辑]
wkjs的公告
[编辑]
文章分类
ajax
C#
C#/C++/C
C++
C语言
JAVA
JavaScriot
javascript
LINUX编程
PHP
Windows Mobile
ZendFramework
计算机网络
企業管理
企業類庫
软件工程
設計模式
数据库
杂记
[编辑]
常去网站
MSDN中文网站
張興華
(RSS)
搏击长空
(RSS)
[编辑]
我的代碼庫
存档
2009年08月(1)
2009年02月(1)
2009年01月(1)
2008年12月(1)
2008年11月(1)
2008年10月(5)
2008年08月(1)
2008年07月(6)
2008年06月(29)
2008年05月(2)
2008年03月(1)
2008年02月(3)
2008年01月(4)
2007年12月(2)
2007年10月(18)
2007年09月(16)
2007年08月(2)
2007年07月(5)
2007年06月(7)
2007年04月(4)
2007年03月(1)
2006年12月(4)
2006年10月(2)
2006年09月(8)
2006年08月(19)
2006年06月(1)
2006年05月(4)
2006年04月(7)
2006年03月(6)
2006年02月(1)
2005年12月(1)
工厂方法模型之PHP实现
收藏
<?php
/**
* @意图:工厂方法模型,定义一个用于创建对象的接口,让子类决定实例化哪一个类。Factory Method使一个类的实例化延迟到其子类
* @适用性:
* 1、当一个类不知道它所必须创建的对象的类的时候
* 2、当一个类希望由它的子类来指定它所创建的对象的时候
* 3、当类创建对象的职责委托给多个帮助子类中的某一个,并且你希望将那一个帮助子类是代理者这一信息局部化的时候
* @author:王康
* @copyright:http://blog.csdn.net/wkjs
*/
?>
<?php
/**
* @name:
* @uses:Page
* @version:1.0.0
* @author:王康
* @copyright:http://blog.csdn.net/wkjs
*/
abstract
class
Page {
}
?>
<?php
/**
* @name:
* @uses:SkillsPage
* @version:1.0.0
* @author:王康
* @copyright:http://blog.csdn.net/wkjs
*/
class
SkillsPage
extends
Page {
}
?>
<?php
/**
* @name:
* @uses:EducationPage
* @version:1.0.0
* @author:王康
* @copyright:http://blog.csdn.net/wkjs
*/
class
EducationPage
extends
Page {
}
?>
<?php
/**
* @name:
* @uses:ExperiencePage
* @version:1.0.0
* @author:王康
* @copyright:http://blog.csdn.net/wkjs
*/
class
ExperiencePage
extends
Page {
}
?>
<?php
/**
* @name:
* @uses:IntroductionPage
* @version:1.0.0
* @author:王康
* @copyright:http://blog.csdn.net/wkjs
*/
class
IntroductionPage
extends
Page {
}
?>
<?php
/**
* @name:
* @uses:ResultsPage
* @version:1.0.0
* @author:王康
* @copyright:http://blog.csdn.net/wkjs
*/
class
ResultsPage
extends
Page {
}
?>
<?php
/**
* @name:
* @uses:ConclusionPage
* @version:1.0.0
* @author:王康
* @copyright:http://blog.csdn.net/wkjs
*/
class
ConclusionPage
extends
Page {
}
?>
<?php
/**
* @name:
* @uses:SummaryPage
* @version:1.0.0
* @author:王康
* @copyright:http://blog.csdn.net/wkjs
*/
class
SummaryPage
extends
Page {
}
?>
<?php
/**
* @name:
* @uses:BibliographyPage
* @version:1.0.0
* @author:王康
* @copyright:http://blog.csdn.net/wkjs
*/
class
BibliographyPage
extends
Page {
}
?>
<?php
/**
* @name:
* @uses:Document
* @version:1.0.0
* @author:王康
* @copyright:http://blog.csdn.net/wkjs
*/
abstract
class
Document {
/**
* This is variable page description
*
* @var mixed
*
*/
public
$page
=
array
();
/**
* This is method __construct
*
* @return mixed This is the return value description
*
*/
public
function
__construct() {
$this
->Document();
}
/**
* This is method Document
*
* @return mixed This is the return value description
*
*/
public
function
Document() {
$this
->CreatePages();
}
/**
* This is method CreatePages
*
* @return mixed This is the return value description
*
*/
public
abstract
function
CreatePages();
}
?>
<?php
/**
* @name:
* @uses:Resume
* @version:1.0.0
* @author:王康
* @copyright:http://blog.csdn.net/wkjs
*/
class
Resume
extends
Document {
/**
* This is method CreatePages
*
* @return mixed This is the return value description
*
*/
public
function
CreatePages() {
$this
->page[]=
new
SkillsPage();
$this
->page[]=
new
EducationPage();
$this
->page[]=
new
ExperiencePage();
}
}
?>
<?php
/**
* @name:
* @uses:Report
* @version:1.0.0
* @author:王康
* @copyright:http://blog.csdn.net/wkjs
*/
class
Report
extends
Document {
/**
* This is method CreatePages
*
* @return mixed This is the return value description
*
*/
public
function
CreatePages() {
$this
->page[]=
new
IntroductionPage();
$this
->page[]=
new
ResultsPage();
$this
->page[]=
new
SummaryPage();
$this
->page[]=
new
BibliographyPage();
}
}
?>
<?php
/**
* @name:
* @uses:调用说明
* @version:1.0.0
* @author:王康
* @copyright:http://blog.csdn.net/wkjs
*/
$documents
=
array
(
new
Resume(),
new
Report());
foreach
(
$documents
as
$value
) {
foreach
((
array
)
$value
->page
as
$cls
) {
echo
get_class(
$cls
).
'<br />'
;
}
echo
'<hr />'
;
}
?>
发表于 @ 2008年10月22日 02:48:00 |
评论(
loading...
)
|
编辑
|
举报
|
收藏
旧一篇:建造者模式之PHP实现
|
新一篇:Javascript简繁网页浏览
查看最新精华文章 请访问博客首页
相关文章
发表评论
表 情:
评论内容:
用 户 名:
登录
注册
匿名评论
验 证 码:
重新获得验证码