-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmorning_facade_example.dart
58 lines (46 loc) · 1.27 KB
/
morning_facade_example.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
55
56
57
58
// Morning Facade Example
class Grinder {
String _type;
Grinder(this._type);
void grind() => print("Grinding $_type!");
}
class Maker {
String _type;
Maker(this._type);
void fill() => print("Filling the $_type maker!");
void retrieve() => print("Retrieving the $_type!");
void start() => print("Starting the $_type maker!");
}
class Imbiber {
String _beverage;
Imbiber(this._beverage);
void drink() => print("Mmmmm...drinking $_beverage!");
}
class MorningFacade {
final _coffeeDrinker = Imbiber("coffee");
final _coffeeGrinder = Grinder("coffee beans");
final _coffeeMaker = Maker("coffee");
void prepareCoffee() {
print("\r\nPreparing the coffee...");
_coffeeGrinder.grind();
_coffeeMaker
..fill()
..start();
print("Coffee is brewing!\r\n");
}
void drinkCoffee() {
print("\r\nMust...have...coffee...");
_coffeeMaker.retrieve();
_coffeeDrinker.drink();
print("This is damn fine coffee!");
}
}
void main() {
var typicalMorning = MorningFacade();
print("Wake up! Grab a brush and put on a little makeup...");
print("\r\nStumble to the kitchen...");
typicalMorning.prepareCoffee();
print("Oh my...that smells good...");
typicalMorning.drinkCoffee();
print("\r\nI'm ready to attack the day!");
}