forked from abishekaditya/DesignPatterns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
40 lines (30 loc) · 1.27 KB
/
Program.cs
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
namespace CompositePattern
{
/// <summary>
/// 组合模式
/// </summary>
static class Program
{
public static void Main()
{
var breakfast = new Menu("Breakfast", "Pancake House");
var lunch = new Menu("Lunch", "Deli Diner");
var dinner = new Menu("Dinner", "Dinneroni");
var dessert = new Menu("Dessert", "Ice Cream");
var menu = new Menu("All", "McDonalds");
breakfast.Add(new MenuItem("Waffles", "Butterscotch waffles", 140, false));
breakfast.Add(new MenuItem("Corn Flakes", "Kellogs", 80, true));
lunch.Add(new MenuItem("Burger", "Cheese and Onion Burger", 250, true));
lunch.Add(new MenuItem("Sandwich", "Chicken Sandwich", 280, false));
dinner.Add(new MenuItem("Pizza", "Cheese and Tomato Pizza", 210, true));
dinner.Add(new MenuItem("Pasta", "Chicken Pasta", 280, false));
dessert.Add(new MenuItem("Ice Cream", "Vanilla and Chocolate", 120, true));
dessert.Add(new MenuItem("Cake", "Choclate Cake Slice", 180, false));
dinner.Add(dessert);
menu.Add(breakfast);
menu.Add(lunch);
menu.Add(dinner);
menu.Print();
}
}
}