Example #1
0
        static void Main(string[] args)
        {
            AnimalFactory Fact = new AnimalFactory();

            Console.WriteLine("What Animal do you want to test?");
            string name = Console.ReadLine();

            IAnimal animal = Fact.GetAnimal(name);

            animal.TryToFly();
            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            var factory = new AnimalFactory();

            var parrot = factory.GetAnimal(Animal.Parrot);

            Console.WriteLine(parrot.Say());

            var tiger = factory.GetAnimal(Animal.Tiger);

            Console.WriteLine(tiger.Say());

            Console.ReadKey();
        }
Example #3
0
        static void Main(string[] args)
        {
            var animalFactory = new AnimalFactory();

            var animal = animalFactory.Get <Cat>();

            animal.SaySomething();

            animal = animalFactory.Get <Dog>();
            animal.SaySomething();

            animal = animalFactory.Get <Spider>();
            animal.SaySomething();
        }
Example #4
0
        public static void Main(string[] args)
        {
            AnimalFactory factory = new AnimalFactory();

            while (true)
            {
                // Add some animals to the pen.
                string input  = Console.ReadLine();
                var    animal = factory.GetAnimal(input);
                if (animal == null)
                {
                    break;
                }
                animal.AnimalNoise();
            }
        }