1
using System;
2
using System.Collections;
3
4
public class MyClass
5
{
6
public static void Main()
7
{
8
Builder builder = new mao();
9
builder.Build();
10
builder.result().CreateProduct();
11
12
builder = new shi();
13
builder.Build();
14
builder.result().CreateProduct();
15
16
builder = new tie();
17
builder.Build();
18
builder.result().CreateProduct();
19
20
Console.WriteLine( "振威镖局建造完毕!镖局金壁辉煌!" );
21
Console.Read();
22
}
23
24
}
25
26
interface Builder{
27
void Build(); //建造方法
28
Product result(); //返回产品
29
}
30
31
class mao:Builder{ //毛利求建造者
32
33
//实现建造方法
34
public void Build(){
35
Console.WriteLine( "我是毛利求,我是负责财务会计日常开销的." );
36
}
37
38
//返回建造结果
39
public Product result(){
40
return new P_mao(); //毛利求完成的产品
41
}
42
43
}
44
45
class shi:Builder{ //时小迁建造者
46
47
//实现建造方法
48
public void Build(){
49
Console.WriteLine( "我是时小迁,我是负责工程的后勤供应的." );
50
}
51
52
//返回建造结果
53
public Product result(){
54
return new S_mao(); //时小迁完成的产品
55
}
56
57
}
58
59
class tie:Builder{ //铁开山建造者
60
61
//实现建造方法
62
public void Build(){
63
Console.WriteLine( "我是铁开山,我是负责日常施工监督的." );
64
}
65
66
//返回建造结果
67
public Product result(){
68
return new T_mao(); //铁开山完成的产品
69
}
70
71
}
72
73
interface Product{ //这里是产品接口.
74
void CreateProduct();
75
}
76
77
class P_mao:Product{ //毛利求的产品
78
public P_mao(){
79
Console.WriteLine( "************** 财务会计日常开销
正常开始 **************" );
80
}
81
82
public void CreateProduct(){
83
Console.WriteLine( "三月后,财务会计日常开销一切正常,没有超支,而且还节省了50万两白银!\n" );
84
}
85
86
}
87
88
class S_mao:Product{ //时小迁的产品
89
public S_mao(){
90
Console.WriteLine( "************** 工程的后勤供应
正常开始 **************" );
91
}
92
93
public void CreateProduct(){
94
Console.WriteLine( "三月后,工程的后勤供应一切正常,我跑前跑后,终于把材料都准备齐全!\n" );
95
}
96
97
}
98
99
class T_mao:Product{ //铁开山的产品
100
public T_mao(){
101
Console.WriteLine( "**************日常施工监督
正常开始**************" );
102
}
103
104
public void CreateProduct(){
105
Console.WriteLine( "三月后,工程的施工一切正常,弟兄们都很配合我,我们施工很顺利!\n" );
106
}
107
108
}
using System;2
using System.Collections;3

4
public class MyClass5
{6
public static void Main()7
{8
Builder builder = new mao();9
builder.Build();10
builder.result().CreateProduct();11
12
builder = new shi();13
builder.Build();14
builder.result().CreateProduct();15
16
builder = new tie();17
builder.Build();18
builder.result().CreateProduct();19
20
Console.WriteLine( "振威镖局建造完毕!镖局金壁辉煌!" );21
Console.Read();22
}23
24
}25

26
interface Builder{27
void Build(); //建造方法28
Product result(); //返回产品29
}30

31
class mao:Builder{ //毛利求建造者32
33
//实现建造方法34
public void Build(){35
Console.WriteLine( "我是毛利求,我是负责财务会计日常开销的." );36
} 37
38
//返回建造结果39
public Product result(){40
return new P_mao(); //毛利求完成的产品41
}42
43
}44

45
class shi:Builder{ //时小迁建造者46
47
//实现建造方法48
public void Build(){49
Console.WriteLine( "我是时小迁,我是负责工程的后勤供应的." );50
} 51
52
//返回建造结果53
public Product result(){54
return new S_mao(); //时小迁完成的产品55
}56
57
}58

59
class tie:Builder{ //铁开山建造者60
61
//实现建造方法62
public void Build(){63
Console.WriteLine( "我是铁开山,我是负责日常施工监督的." );64
} 65
66
//返回建造结果67
public Product result(){68
return new T_mao(); //铁开山完成的产品69
}70
71
}72

73
interface Product{ //这里是产品接口.74
void CreateProduct();75
}76

77
class P_mao:Product{ //毛利求的产品78
public P_mao(){79
Console.WriteLine( "************** 财务会计日常开销
正常开始 **************" );80
}81
82
public void CreateProduct(){83
Console.WriteLine( "三月后,财务会计日常开销一切正常,没有超支,而且还节省了50万两白银!\n" );84
}85
86
}87

88
class S_mao:Product{ //时小迁的产品89
public S_mao(){90
Console.WriteLine( "************** 工程的后勤供应
正常开始 **************" );91
}92
93
public void CreateProduct(){94
Console.WriteLine( "三月后,工程的后勤供应一切正常,我跑前跑后,终于把材料都准备齐全!\n" );95
}96
97
}98

99
class T_mao:Product{ //铁开山的产品100
public T_mao(){101
Console.WriteLine( "**************日常施工监督
正常开始**************" );102
}103
104
public void CreateProduct(){105
Console.WriteLine( "三月后,工程的施工一切正常,弟兄们都很配合我,我们施工很顺利!\n" );106
}107
108
}

浙公网安备 33010602011771号