示例#1
0
        static void Main(string[] args)
        {
            IFruitGardener[] fruitGardeners = new IFruitGardener[3];
            fruitGardeners[0] = new AppleGardener();
            fruitGardeners[1] = new GrapeGardener();
            fruitGardeners[2] = new StrawberryFruitGardener();

            foreach (IFruitGardener fruitGardener in fruitGardeners)
            {
                IFruit fruit = fruitGardener.Factory();
                Demo(fruit);
            }

            Console.ReadLine();
        }
示例#2
0
        static void Main(string[] args)
        {
            IFruitGardener[] fruitGardeners = new IFruitGardener[3];
            fruitGardeners[0] = new AppleGardener();
            fruitGardeners[1] = new GrapeGardener();
            fruitGardeners[2] = new StrawberryFruitGardener();

            foreach (IFruitGardener fruitGardener in fruitGardeners)
            {
                IFruit fruit = fruitGardener.Factory();
                Demo(fruit);
            }

            Console.ReadLine();
        }