forked from gennad/Design-Patterns-in-Python
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfacade.py
More file actions
29 lines (24 loc) · 629 Bytes
/
facade.py
File metadata and controls
29 lines (24 loc) · 629 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Complex parts
class CPU:
def freeze(self): pass
def jump(self, position): pass
def execute(self): pass
class Memory:
def load(self, position, data): pass
class HardDrive:
def read(self, lba, size): pass
# Facade
class Computer:
def __init__(self):
self.cpu = CPU()
self.memory = Memory()
self.hard_drive = HardDrive()
def start_computer(self):
self.cpu.freeze()
self.memory.load(0, self.hard_drive.read(0, 1024))
self.cpu.jump(10)
self.cpu.execute()
# Client
if __name__ == '__main__':
facade = Computer()
facade.start_computer()