static void Main(string[] args)
        {
            IAnimalFactory tigerFactory = new TigerFactory();
            IAnimal        aTiger       = tigerFactory.CreateAnimal();

            aTiger.Speak();
            aTiger.Action();


            IAnimalFactory dogFactory = new DogFactory();
            IAnimal        aDog       = dogFactory.CreateAnimal();

            aDog.Speak();
            aDog.Action();

            Console.ReadKey();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("***Factory Pattern Demo***\n");
            // Creating a Tiger Factory
            IAnimalFactory tigerFactory = new TigerFactory();
            // Creating a tiger using the Factory Method
            IAnimal aTiger = tigerFactory.CreateAnimal();

            aTiger.Speak();
            aTiger.Action();
            // Creating a DogFactory
            IAnimalFactory dogFactory = new DogFactory();
            // Creating a dog using the Factory Method
            IAnimal aDog = dogFactory.CreateAnimal();

            aDog.Speak();
            aDog.Action();
            Console.ReadKey();
        }