-
Notifications
You must be signed in to change notification settings - Fork 1
/
2-5-facade.vala
58 lines (46 loc) · 1.12 KB
/
2-5-facade.vala
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
class Computer {
public void get_electric_shock () {
print ("Ouch!\n");
}
public void make_sound () {
print ("Beep beep!\n");
}
public void show_loading_screen () {
print ("Loading...\n");
}
public void bam () {
print ("Ready to be used!\n");
}
public void close_everything () {
print ("Bup bup bup buzzzz!\n");
}
public void sooth () {
print ("Zzzzz\n");
}
public void pull_current () {
print ("Haaah!\n");
}
}
class ComputerFacade {
protected Computer computer;
public ComputerFacade (Computer computer) {
this.computer = computer;
}
public void turn_on () {
computer.get_electric_shock ();
computer.make_sound ();
computer.show_loading_screen ();
computer.bam ();
}
public void turn_off () {
computer.close_everything ();
computer.pull_current ();
computer.sooth ();
}
}
public int main (string[] args) {
var computer = new ComputerFacade (new Computer());
computer.turn_on ();
computer.turn_off ();
return 0;
}