最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Python實(shí)現(xiàn)的建造者模式示例

 更新時(shí)間:2018年08月06日 11:59:20   作者:初行  
這篇文章主要介紹了Python實(shí)現(xiàn)的建造者模式,結(jié)合完整實(shí)例形式分析了構(gòu)造者模式的具體定義與相關(guān)使用操作技巧,需要的朋友可以參考下

本文實(shí)例講述了Python實(shí)現(xiàn)的建造者模式。分享給大家供大家參考,具體如下:

#!/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'構(gòu)建%s的頭' % self.type
  def BuildBody(self):
    print u'構(gòu)建%s的身體' % self.type
  def BuildArm(self):
    print u'構(gòu)建%s的手' % self.type
  def BuildLeg(self):
    print u'構(gòu)建%s的腳' % self.type
#瘦子
class PersonThinBuilder(PersonBuilder):
  type = u'瘦子'
  def BuildHead(self):
    print u'構(gòu)建%s的頭' % self.type
  def BuildBody(self):
    print u'構(gòu)建%s的身體' % self.type
  def BuildArm(self):
    print u'構(gòu)建%s的手' % self.type
  def BuildLeg(self):
    print u'構(gò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();

運(yùn)行結(jié)果:

構(gòu)建瘦子的頭
構(gòu)建瘦子的身體
構(gòu)建瘦子的手
構(gòu)建瘦子的腳
構(gòu)建胖子的頭
構(gòu)建胖子的身體
構(gòu)建胖子的手
構(gòu)建胖子的腳

更多關(guān)于Python相關(guān)內(nèi)容可查看本站專題:《Python數(shù)據(jù)結(jié)構(gòu)與算法教程》、《Python Socket編程技巧總結(jié)》、《Python函數(shù)使用技巧總結(jié)》、《Python字符串操作技巧匯總》及《Python入門與進(jìn)階經(jīng)典教程

希望本文所述對(duì)大家Python程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論

庆阳市| 四子王旗| 多伦县| 运城市| 兰考县| 东乌珠穆沁旗| 六安市| 滦平县| 田阳县| 越西县| 宝山区| 盐池县| 蒙阴县| 西昌市| 当涂县| 金乡县| 梅州市| 锡林浩特市| 南康市| 连州市| 丹寨县| 临猗县| 体育| 崇明县| 浙江省| 天全县| 江达县| 海晏县| 外汇| 宁武县| 广河县| 本溪| 平潭县| 乐安县| 喀喇| 延吉市| 福泉市| 博湖县| 屯留县| 沂水县| 乐至县|