-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathProgram.cs
94 lines (78 loc) · 1.74 KB
/
Program.cs
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
83
84
85
86
87
88
89
90
91
92
93
94
using System;
namespace TemplateMethodPattern
{
abstract class Builder
{
// Template method
public void Build()
{
Test();
Lint();
Assemble();
Deploy();
}
abstract public void Test();
abstract public void Lint();
abstract public void Assemble();
abstract public void Deploy();
}
class AndroidBuilder : Builder
{
public override void Assemble()
{
Console.WriteLine("Assembling the android build");
}
public override void Deploy()
{
Console.WriteLine("Deploying android build to server");
}
public override void Lint()
{
Console.WriteLine("Linting the android code");
}
public override void Test()
{
Console.WriteLine("Running android tests");
}
}
class IosBuilder : Builder
{
public override void Assemble()
{
Console.WriteLine("Assembling the ios build");
}
public override void Deploy()
{
Console.WriteLine("Deploying ios build to server");
}
public override void Lint()
{
Console.WriteLine("Linting the ios code");
}
public override void Test()
{
Console.WriteLine("Running ios tests");
}
}
class Program
{
static void Main(string[] args)
{
var androidBuilder = new AndroidBuilder();
androidBuilder.Build();
// Output:
// Running android tests
// Linting the android code
// Assembling the android build
// Deploying android build to server
var iosBuilder = new IosBuilder();
iosBuilder.Build();
// Output:
// Running ios tests
// Linting the ios code
// Assembling the ios build
// Deploying ios build to server
Console.ReadLine();
}
}
}