Beispiel #1
0
        static void BuilderPattern()
        {
            Console.WriteLine("建造者模式");
            Meal vegMeal = new MealBuilder().PrepareVegMeal();

            vegMeal.AddItem(new Pepsi());
            vegMeal.ShowItems();
            Console.WriteLine("总计:" + vegMeal.GetCost());
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            MealBuilder mealBuilder = new MealBuilder();
            Meal        vegMeal     = mealBuilder.prepareVegMeal();

            System.Console.WriteLine("Veg Meal");
            Console.ReadKey();
            vegMeal.showItems();
            System.Console.WriteLine("Total COst :" + vegMeal.getCost());
            Console.ReadKey();
            Meal nonVegMeal = mealBuilder.prepareNonVegMeal();

            System.Console.WriteLine(" \n \n nonVegMeal : ");
            Console.ReadKey();
            nonVegMeal.showItems();
            System.Console.WriteLine("Total cost" + nonVegMeal.getCost());
            Console.ReadKey();
        }