#!/usr/bin/python
# -*- coding:utf-8 -*-
#建造者基類
class PersonBuilder():
def BuildHead(self):🜎 ):
pass
def BuildArm(self):
pass
Builder(PersonBuilder):
type = u'胖子'
def BuildHead(self): PRint u'構建%s的頭' % self.type
def BuildBody(self):
print u'構建%s的身體' % self.type
構建 print u% 的構建 %手' % self.type
def BuildLeg(self):
print u'建構%s的腳' % self.type
#==m
#on; def BuildHead (self):
print u'建構%s的頭' % self.type
def BuildBody(self):
print u'建構%s的手' % self.type
def BuildLeg(self):
print u'建構%s的腳' % self.type
# 指揮家
def __init__(self, pb):
self.pb = pb
def CreatePereson(self):
b.BuildBody()
self.pb.BuildArm()
self. pb.BuildLeg()
def clientUI():
pb = PersonThinBuilder()
pd = PersonDirector(pb)
Personpd.CateP. pd = PersonDirector(pb)
pd.CreatePereson( )
return
if __name__ == '__main__':
clientUI();
以上是Python_建造者模式的內容,中文相關網(PHPcnphp)請關注PHPcnphp.