#!/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 ' fat '
def buildhead (self): PRint u ' build%s header '% Self.type
def buildbody (self):
Print U ' build%s's body '% Self.type
def buildarm (self):
Print U ' build%s's hand '% Self.type
def buildleg (self):
Print U ' build%s's feet '% self.type
#瘦子
Class Personthinbuilder (Personbuilder):
Type = U ' thin '
def buildhead (self):
Print U ' build%s's head '% Self.type
def buildbody (self):
Print U ' build%s's body '% Self.type
def buildarm (self):
Print U ' build%s's hand '% Self.type
def buildleg (self):
Print U ' build%s's feet '% 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 ();
The above is the Python_ Builder model content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!