当前位置: 首页>>代码示例>>C#>>正文


C# Menu.add方法代码示例

本文整理汇总了C#中System.Web.UI.WebControls.Menu.add方法的典型用法代码示例。如果您正苦于以下问题:C# Menu.add方法的具体用法?C# Menu.add怎么用?C# Menu.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.UI.WebControls.Menu的用法示例。


在下文中一共展示了Menu.add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            var dinnerMenu = new DinnerMenu();
            var breakfastMenu = new BreakfastMenu();
            var  cafeMenu = new CafeMenu();

            MenuComponent breakfastCMenu = new Menu("PANCAKE HOUSE", "Breakfast");
            MenuComponent dinnerCMenu = new Menu("FINE DINING ITALIAN", "Dinner");
            MenuComponent coffeeCMenu = new Menu("THE TEA HOSE", "Tea Time");
            MenuComponent foodCourtMenu = new Menu("THE FOOD COURT - 24 Hours", "All day food");

            foodCourtMenu.add(breakfastCMenu);
            foodCourtMenu.add(dinnerCMenu);
            foodCourtMenu.add(coffeeCMenu);

            MenuItem pasta = new MenuItem(5, "Lunch: Pasta", "Pasta", false);
            MenuItem soup = new MenuItem(10, "Lunch: Soup", "Soup", true);
            MenuItem salad = new MenuItem(15, "Lunch: Salda", "Salda", true);

            MenuItem tea = new MenuItem(6, "Tea Time: Tea", "Tea", true);
            MenuItem biscuit = new MenuItem(9, "Tea Time: Biscuit", "Biscuit", false);
            MenuItem cake = new MenuItem(12, "Tea Time: Cake", "Cake", false);

            MenuItem coffee = new MenuItem(11, "Breakfast: Coffee", "Coffee", true);
            MenuItem fruit = new MenuItem(22, "Breakfast: Fruit", "Fruit", true);
            MenuItem muesly = new MenuItem(33, "Breakfast: Muesly", "Muesly", false);

            breakfastCMenu.add(coffee);
            breakfastCMenu.add(fruit);
            breakfastCMenu.add(muesly);

            dinnerCMenu.add(pasta);
            dinnerCMenu.add(soup);
            dinnerCMenu.add(salad);

            coffeeCMenu.add(tea);
            coffeeCMenu.add(biscuit);
            coffeeCMenu.add(cake);

            WaitressComposite superWaittress = new WaitressComposite(foodCourtMenu);

            superWaittress.printMenu();

            Console.ReadLine();

            var javaWaitress = new JavaWaitressIterator(breakfastMenu, dinnerMenu, cafeMenu);

            var dinnerOrderId = javaWaitress.AddMenu(dinnerMenu);
            var breakfastOrderId = javaWaitress.AddMenu(breakfastMenu);
            var cafeOrderId = javaWaitress.AddMenu(cafeMenu);

            javaWaitress.PrintOrder(dinnerOrderId);
            javaWaitress.PrintOrder(breakfastOrderId);
            javaWaitress.PrintOrder(cafeOrderId);

            javaWaitress.PrintOrders();

            javaWaitress.PrintOrdersWithIterators();

            Console.ReadLine();

            return;

            Console.WriteLine("Testing New Cafe Menu added");

            javaWaitress.printCafeMenu_WithEnumerator();

            javaWaitress.printCafeMenu_WithIterator();

            Console.ReadLine();
            return;

            Console.WriteLine("\nPrinting BREAKFAST MENU_____________________");
            javaWaitress.printBreakfastMenu_WithEnumerator();

            Console.WriteLine("\nPrinting LUNCH MENU_____________________");
            javaWaitress.printDinnerMenu_WithEnumerator();

            Console.WriteLine("\nPrinting ALL menu_____________________");
            javaWaitress.printMenu();

            Console.WriteLine("\nPrinting vegetarian dishes_____________________");

            Console.WriteLine("Item {0} is vegetarian: {1}", "Set A", javaWaitress.isItemVegetarian("Set A"));
            Console.WriteLine("Item {0} is vegetarian: {1}", "Set B", javaWaitress.isItemVegetarian("Set B"));
            Console.WriteLine("Item {0} is vegetarian: {1}", "Set C", javaWaitress.isItemVegetarian("Set C"));
            Console.WriteLine("Item {0} is vegetarian: {1}", "Set D", javaWaitress.isItemVegetarian("Set D"));

            Console.WriteLine("Item {0} is vegetarian: {1}", "Dinner Set A", javaWaitress.isItemVegetarian("Dinner Set A"));
            Console.WriteLine("Item {0} is vegetarian: {1}", "Dinner Set B", javaWaitress.isItemVegetarian("Dinner Set B"));
            Console.WriteLine("Item {0} is vegetarian: {1}", "Dinner Set C", javaWaitress.isItemVegetarian("Dinner Set C"));
            Console.WriteLine("Item {0} is vegetarian: {1}", "Dinner Set D", javaWaitress.isItemVegetarian("Dinner Set D"));

            Console.ReadLine();
        }
开发者ID:jhuerta,项目名称:DesignPatterns_Tutorial_HeadFirst,代码行数:95,代码来源:Program.cs


注:本文中的System.Web.UI.WebControls.Menu.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。