#!/usr/bin/python
# -*- coding:utf-8 -*-
#Builder base class
class PersonBuilder():
def BuildHead(self):
def BuildBody(self ):
PASSf DEF Buildarm (Self):
Pass
DEF Buildleg (Self):
Pass
#Fatty
Class Personfatbuilder (PersonBuilder):
Type = U 'Fat Buildhead (fat man' Self: Print u'Build the head of %s' % self.type
def BuildBody(self):
print u'Build the body of %s' % self.type
def BuildArm(self):
print u'Build the body of %s % self.type
def BuildLeg(self):
% self.type
(self):
print u 'Build the head of %s' % self.type
def BuildBody(self):
print u 'Build the body of %s' % self.type
def BuildArm(self):
u'Build %s's hand' % self.type
def BuildLeg(self):
print u'Build %s's foot' % self.type
#Director
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 content of Python_builder mode. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!