Esempio n. 1
0
        static void Main(string[] args)
        {
            AbstractCreator[] creators = new AbstractCreator[2];

            creators[0] = new ConcreteCreatorA();
            creators[1] = new ConcreteCreatorB();

            foreach (AbstractCreator creator in creators)
            {
                AbstractProduct product = creator.CreateProduct();
                Console.WriteLine("Created {0}", product.GetType().Name);
            }

            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            // An array of creators
            Creator[] creators = new Creator[2];
            creators[0] = new ConcreteCreatorA();
            creators[1] = new ConcreteCreatorB();

            // Iterate over creators and create products

            foreach (Creator creator in creators) {
                Product product = creator.FactoryMethod();
                Console.WriteLine("Created {0}", product.GetType().Name);

            }
            //wait for user input
            Console.Read();
        }