Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Abstract Factory Pattern");

            //making a wild dog and a wild tiger with WildAnimalFactory
            IAnimalFactory animalFactory = FactoryProvider.GetAnimalFactory(AnimalType.Wild);
            IDog           dog           = animalFactory.GetDog();
            ITiger         tiger         = animalFactory.GetTiger();

            dog.AboutMe();
            tiger.AboutMe();

            Console.WriteLine("--------------------------------------------------------");

            //making a pet dog and a pet tiger with PetAnimalFactory
            animalFactory = FactoryProvider.GetAnimalFactory(AnimalType.Pet);
            dog           = animalFactory.GetDog();
            tiger         = animalFactory.GetTiger();
            dog.AboutMe();
            tiger.AboutMe();

            Console.Read();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("***Abstract Factory Pattern Demo.***\n");

            //Making a wild dog and wild tiger through WildAnimalFactory
            IAnimalFactory animalFactory = FactoryProvider.GetAnimalFactory("wild");
            IDog           dog           = animalFactory.GetDog();
            ITiger         tiger         = animalFactory.GetTiger();

            dog.AboutMe();
            tiger.AboutMe();

            Console.WriteLine("******************");

            //Making a pet dog and pet tiger through PetAnimalFactory now.
            animalFactory = FactoryProvider.GetAnimalFactory("pet");
            dog           = animalFactory.GetDog();
            tiger         = animalFactory.GetTiger();
            dog.AboutMe();
            tiger.AboutMe();

            Console.ReadLine();
        }