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
37 lines (29 loc) · 950 Bytes
/
Program.cs
File metadata and controls
37 lines (29 loc) · 950 Bytes
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
using System;
namespace DecoratorPattern
{
internal class Program
{
public static void Main(string[] args)
{
#region Prototype
Component component = new ConcreteComponent();
Decorator decorator = new DecoratorA();
decorator.SetComponent(component);
decorator.Operation();
Decorator decorator1 = new DecoratorB();
decorator1.SetComponent(decorator);
decorator1.Operation();
#endregion Prototype
var person = new Person("小明");
Console.WriteLine("\n第一种装扮:\n");
var pants = new Pants();
pants.Decorate(person);
pants.Show();
Console.WriteLine("\n第二种装扮:\n");
var shirts = new Tshirts();
shirts.Decorate(pants);
shirts.Show();
Console.ReadLine();
}
}
}