class CPU(object):
def run(self):
print('CPU run')
def stop(self):
print('CPU stop')
class Disk(object):
def run(self):
print('Disk run')
def stop(self):
print('Disk stop')
class Memory(object):
def run(self):
print('Memory run')
def stop(self):
print('Memory stop')
class Computer(object):
# facade 外观,底层子系统封装,统一的来调用
def __init__(self):
self.cpu = CPU()
self.disk = Disk()
self.memory = Memory()
def run(self):
self.cpu.run()
self.disk.run()
self.memory.run()
def stop(self):
self.cpu.stop()
self.disk.stop()
self.memory.stop()
# Client
computer = Computer()
computer.run()
computer.stop()