Python_建造者模式
2024-08-26 17:12:53
#!/usr/bin/python
# -*- coding:utf-8 -*- #建造者基类
class PersonBuilder():
def BuildHead(self):
pass def BuildBody(self):
pass def BuildArm(self):
pass def BuildLeg(self):
pass #胖子
class PersonFatBuilder(PersonBuilder):
type = u'胖子'
def BuildHead(self):
print u'构建%s的头' % self.type def BuildBody(self):
print u'构建%s的身体' % self.type def BuildArm(self):
print u'构建%s的手' % self.type def BuildLeg(self):
print u'构建%s的脚' % self.type #瘦子
class PersonThinBuilder(PersonBuilder):
type = u'瘦子'
def BuildHead(self):
print u'构建%s的头' % self.type def BuildBody(self):
print u'构建%s的身体' % self.type def BuildArm(self):
print u'构建%s的手' % self.type def BuildLeg(self):
print u'构建%s的脚' % self.type #指挥者
class PersonDirector():
pb = None;
def __init__(self, pb):
self.pb = pb def CreatePereson(self):
self.pb.BuildHead()
self.pb.BuildBody()
self.pb.BuildArm()
self.pb.BuildLeg() def clientUI():
pb = PersonThinBuilder()
pd = PersonDirector(pb)
pd.CreatePereson() pb = PersonFatBuilder()
pd = PersonDirector(pb)
pd.CreatePereson()
return if __name__ == '__main__':
clientUI();
最新文章
- ACCEPTANCE CRITERIA FOR USER STORIES
- Intellij 常用快捷键
- A trip through the Graphics Pipeline 2011_07_Z/Stencil processing, 3 different ways
- 部署ganglia3.7
- day3 python 集合 文件
- UVa 297 - Quadtrees
- zabbix oracle监控插件orabbix部署安装
- Linux shell (一)
- javascript之尺寸,位置,溢出
- ASP.NET Core 实战:使用 Docker 容器化部署 ASP.NET Core + MySQL + Nginx
- widows10 安装1803 版本后不能访问网络上的机器解决方法
- vue结构详解
- SpringMVC 使用 MultipartFile 实现文件上传
- java_字段声明
- 第一篇:服务的注册与发现Eureka(Finchley版本)
- xml文件里 用js语句获取 当前时间
- 03.设计模式_抽象工厂模式(Abstract Fcatory)
- swift - 正则表达式
- C++11 使用 std::async创建异步程序
- 如何在 Django 中保证并发的数据一致性
热门文章
- Python3练习题系列(08)——代码阅读方法及字典跳转表理解
- 吐槽下intellij idea 2018.3这个版本
- perl debug
- keybd_event 被 SendInput 替代
- Tensorflow 之finetune微调模型方法&;&;不同层上设置不同的学习率
- javascript数据类型的判断
- Linux性能分析流程图
- SpringBoot中配置起动时的数据库初始化角本
- Long polling failed, will retry in 16 seconds. appId: zeus-guard, cluster: default, namespaces: application, long polling url: null, reason: Get config services failed from···
- C# 读写文件摘要