-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
49 lines (40 loc) · 1.08 KB
/
index.ts
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
class SubSystem1 {
public operation1(): string {
return 'Subsystem1: Ready!\n'
}
public operationN(): string {
return 'Subsystem1: Go!\n'
}
}
class SubSystem2 {
public operation1(): string {
return 'Subsystem2: Get Ready!\n'
}
public operationZ(): string {
return 'Subsystem2: Fire!\n'
}
}
class Facade {
protected subsystem1: SubSystem1;
protected subsystem2: SubSystem2;
constructor(subsystem1: SubSystem1 = null, subsystem2: SubSystem2 = null) {
this.subsystem1 = subsystem1 || new SubSystem1()
this.subsystem2 = subsystem2 || new SubSystem2()
}
public operation(): string {
let result = 'Facade initializes subsystems:\n';
result += this.subsystem1.operation1();
result += this.subsystem2.operation1();
result += 'Facade orders subsystems to perform the action:\n';
result += this.subsystem1.operationN();
result += this.subsystem2.operationZ();
return result;
}
}
function clientCodeContext() {
const facade = new Facade()
console.log(facade.operation());
}
export function facade() {
clientCodeContext()
}