-
Notifications
You must be signed in to change notification settings - Fork 1
/
3-10-template.vala
82 lines (67 loc) · 1.58 KB
/
3-10-template.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
abstract class Builder {
// Template method
public void build()
{
this.test();
this.lint();
this.assemble();
this.deploy();
}
public abstract void test();
public abstract void lint();
public abstract void assemble();
public abstract void deploy();
}
class AndroidBuilder : Builder {
public override void test()
{
print ("Running android tests\n");
}
public override void lint()
{
print ("Linting the android code\n");
}
public override void assemble()
{
print ("Assembling the android build\n");
}
public override void deploy()
{
print ("Deploying android build to server\n");
}
}
class IosBuilder : Builder {
public override void test()
{
print ("Running ios tests\n");
}
public override void lint()
{
print ("Linting the ios code\n");
}
public override void assemble()
{
print ("Assembling the ios build\n");
}
public override void deploy()
{
print ("Deploying ios build to server\n");
}
}
public int main (string[] args) {
var android_builder = new AndroidBuilder();
android_builder.build ();
// Output:
// Running android tests
// Linting the android code
// Assembling the android build
// Deploying android build to server
var ios_builder = new IosBuilder ();
ios_builder.build ();
// Output:
// Running ios tests
// Linting the ios code
// Assembling the ios build
// Deploying ios build to server
return 0;
}