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
35 lines (27 loc) · 943 Bytes
/
Program.cs
File metadata and controls
35 lines (27 loc) · 943 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
using System;
namespace CommandPattern
{
public class Program
{
public static void Main(string[] args)
{
#region Prototype
var receiver = new Receiver();
var command = new ConcreteCommand(receiver);
var invoker = new Invoker();
invoker.SetCommand(command);
invoker.ExecuteCommand();
#endregion Prototype
var barbecuer = new Barbecuer();
var waiter = new Waiter();
waiter.SetOrder(new BakeChickenWingCommand(barbecuer));
waiter.SetOrder(new BakeMuttonCommand(barbecuer));
waiter.SetOrder(new BakeMuttonCommand(barbecuer));
var willCancelOrder = new BakeMuttonCommand(barbecuer);
waiter.SetOrder(willCancelOrder);
waiter.CancelOrder(willCancelOrder);
waiter.Notify();
Console.ReadLine();
}
}
}