forked from WeihanLi/DesignPatterns
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
50 lines (38 loc) · 1.47 KB
/
Program.cs
File metadata and controls
50 lines (38 loc) · 1.47 KB
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
using System;
namespace CompositePattern
{
public class Program
{
public static void Main(string[] args)
{
#region Tree
var root = new Composite("root");
root.Add(new Leaf("Leaf A"));
root.Add(new Leaf("Leaf B"));
var co = new Composite("CompositeA");
co.Add(new Leaf("Leaf X"));
co.Add(new Leaf("Leaf Y"));
var co1 = new Composite("CompositeA");
co1.Add(new Leaf("Leaf P"));
co1.Add(new Leaf("Leaf Q"));
co.Add(co1);
root.Add(co);
root.Display(0);
#endregion Tree
#region Company
Company company = new ConcreteCompany("华隆总公司");
var huaDongCompany = new ConcreteCompany("华隆华东分公司");
var huaBeiCompany = new ConcreteCompany("华隆华北分公司");
company.Add(huaDongCompany);
company.Add(huaBeiCompany);
huaDongCompany.Add(new HrDepartment("华隆华东分公司Hr部门"));
huaDongCompany.Add(new FinanceDepartment("华隆华东分公司财务部门"));
huaBeiCompany.Add(new HrDepartment("华隆华北分公司Hr部门"));
huaBeiCompany.Add(new FinanceDepartment("华隆华北分公司财务部门"));
company.Display(0);
company.LineOfDuty();
#endregion Company
Console.ReadLine();
}
}
}