python版本的外观模式

# -*- coding:UTF-8 -*-


class SubSystemOne:
    def method_one(self):
        print("子系统方法一")


class SubSystemTwo:
    def method_two(self):
        print("子系统方法二")


class SubSystemThree:
    def method_three(self):
        print("子系统方法三")


class SubSystemFour:
    def method_four(self):
        print("子系统方法四")


class Facade:
    def __init__(self):
        self.one = SubSystemOne()
        self.two = SubSystemTwo()
        self.three = SubSystemThree()
        self.four = SubSystemFour()

    def method1(self):
        print("方法组1 ====")
        self.one.method_one()
        self.two.method_two()

    def method2(self):
        print("方法组2 ===")
        self.three.method_three()
        self.four.method_four()


if __name__ == "__main__":
    facade = Facade()
    facade.method1()
    facade.method2()

 

posted @ 2018-01-25 15:20  gjw  阅读(105)  评论(0)    收藏  举报