|
外观模式:为一组调用提供一致的接口。
代码:
- import pyb
- class SubSystemOne:
- def MethodOne(self):
- print "SubSysOne"
- class SubSystemTwo:
- def MethodTwo(self):
- print "SubSysTwo"
- class SubSystemThree:
- def MethodThree(self):
- print "SubSysThree"
- class SubSystemFour:
- def MethodFour(self):
- print "SubSysFour"
- class Facade:
- def __init__(self):
- self.one = SubSystemOne()
- self.two = SubSystemTwo()
- self.three = SubSystemThree()
- self.four = SubSystemFour()
- def MethodA(self):
- print "MethodA"
- self.one.MethodOne()
- self.two.MethodTwo()
- self.four.MethodFour()
- def MethodB(self):
- print "MethodB"
- self.two.MethodTwo()
- self.three.MethodThree()
- if __name__ == "__main__":
- facade = Facade()
- facade.MethodA()
- facade.MethodB()
复制代码
将众多的功能函数分别组成不同的组别,通过接口调用某组功能。
黄瓜、鸡蛋、木耳、西红柿、芹菜、茄子。。。。。。,我能做出木须肉、西红柿炒鸡蛋。。。。。。
|
|