Python
設計模式
門面模式
class Sub_A:
def Start_A_Part(self):
print('A Part Start')
def Stop_A_Part(self):
print('A Part Stop')
class Sub_B:
def Start_B_Part(self):
print('B Part Start')
def Stop_B_Part(self):
print('B Part Stop')
class Sub_C:
def Start_C_Part(self):
print('C Part Start')
def Stop_C_Part(self):
print('C Part Stop')
class System:
def __init__(self):
self.A = Sub_A()
self.B = Sub_B()
self.C = Sub_C()
def start_system(self):
self.A.Start_A_Part()
self.B.Start_B_Part()
self.C.Start_C_Part()
def stop_system(self):
self.C.Stop_C_Part()
self.B.Stop_B_Part()
self.A.Stop_A_Part()
S = System()
S.start_system()
print('wait 3 second')
S.stop_system()
程式碼說明
定義三個子系統,並建立在系統中,以順序啟動,再依順序停止
留言
張貼留言