Example #1
0
 static void Main(string[] args)
 {
     #region 非简单工厂模式的实现方式
     //Customer c = new Customer();
     //Food food1 = c.Cook("TomatoScrambleEgg");
     //Food food2 = c.Cook("PepperScrambleMeat");
     //Food food3 = c.Cook("KFC");
     //food1.Print();
     //food2.Print();
     //food3.Print();
     #endregion
     #region 简易工厂模式的实现方法
     Customer c     = new Customer();
     Food     food1 = FoodSimpleFactory.getFood("TomatoScrambleEgg");
     Food     food2 = FoodSimpleFactory.getFood("PepperScrambleMeat");
     Food     food3 = FoodSimpleFactory.getFood("KFC");
     c.GetFood(food1);
     c.GetFood(food2);
     c.GetFood(food3);
     food1.Print();
     food2.Print();
     food3.Print();
     #endregion
     Console.ReadKey();
 }
Example #2
0
        static void Main(string[] args)
        {
            Foods food1 = FoodSimpleFactory.CreateFood("西红柿炒鸡蛋");

            food1.Print();
            Foods food2 = FoodSimpleFactory.CreateFood("土豆炖肉");

            food2.Print();
        }
Example #3
0
        public void Main()
        {
            // 顾客想点一份番茄炒蛋
            Food2 food1 = FoodSimpleFactory.CreateFood("番茄炒蛋");

            food1.Print();

            // 顾客想点一份土豆炒肉
            Food2 food2 = FoodSimpleFactory.CreateFood("土豆肉丝");

            food2.Print();
        }