-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFacade.dart
54 lines (39 loc) · 1.04 KB
/
Facade.dart
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
50
51
52
53
54
import 'package:design_pattern_dart/Display/Example.dart';
class Facade extends Example {
Facade([String filePath = "lib/Structural/Facade.dart"]) : super(filePath);
@override
String testRun() {
Computer computer = Computer();
ComputerFacade facade = ComputerFacade(computer);
return """
// Now turn on the computer.
${facade.turnOn()}
// Turn off the computer.
${facade.turnOff()}
""";
}
}
class Computer {
String getElectricShock() => "Ouch!";
String makeSound() => "Beep beep!";
String showLoadingScreen() => "Loading...";
String bam() => "Ready to be used!";
String closeEverything() => "Bup bup bup buzzzz!";
String sooth() => "ZZzzz";
String pullCurrent() => "Haaah!";
}
class ComputerFacade {
Computer computer;
ComputerFacade(this.computer);
String turnOn() => """
${computer.getElectricShock()}
${computer.makeSound()}
${computer.showLoadingScreen()}
${computer.bam()}
""";
String turnOff() => """
${computer.closeEverything()}
${computer.pullCurrent()}
${computer.sooth()}
""";
}