forked from exceptionnotfound/DesignPatterns
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
49 lines (41 loc) · 1.83 KB
/
Copy pathProgram.cs
File metadata and controls
49 lines (41 loc) · 1.83 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Decorator
{
class Program
{
/// <summary>
/// We run a farm-fresh restaurant.
/// That means that we can only make dishes which we have the ingredients for.
/// Sometimes we run out of ingredients, so we can't make those dishes.
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
{
//Step 1: Define some dishes, and how many of each we can make
FreshSalad caesarSalad = new FreshSalad("Crisp romaine lettuce", "Freshly-grated Parmesan cheese", "House-made Caesar dressing");
caesarSalad.Display();
Pasta fettuccineAlfredo = new Pasta("Fresh-made daily pasta", "Creamly garlic alfredo sauce");
fettuccineAlfredo.Display();
Console.WriteLine("\nMaking these dishes available.");
//Step 2: Decorate the dishes; now if we attempt to order them once we're out of ingredients, we can notify the customer
Available caesarAvailable = new Available(caesarSalad, 3);
Available alfredoAvailable = new Available(fettuccineAlfredo, 4);
//Step 3: Order a bunch of dishes
caesarAvailable.OrderItem("John");
caesarAvailable.OrderItem("Sally");
caesarAvailable.OrderItem("Manush");
alfredoAvailable.OrderItem("Sally");
alfredoAvailable.OrderItem("Francis");
alfredoAvailable.OrderItem("Venkat");
alfredoAvailable.OrderItem("Diana");
alfredoAvailable.OrderItem("Dennis"); //There won't be enough for this order.
caesarAvailable.Display();
alfredoAvailable.Display();
Console.ReadKey();
}
}
}