Пример #1
0
        private static void FactoryExample()
        {
            IAnimalFactory factory   = AnimalFactory.CreateFactory();
            IAnimal        carnivore = factory.CreateAnimal(AnimalType.Carnivore);
            IAnimal        herbivore = factory.CreateAnimal(AnimalType.Herbivore);

            Console.WriteLine("I am a {0}, i sleep for {1} hours and like to eat {2}", carnivore.GetType().Name, carnivore.Sleep(), carnivore.Eat());
            Console.WriteLine("I am a {0}, i sleep for {1} hours and like to eat {2}", herbivore.GetType().Name, herbivore.Sleep(), herbivore.Eat());
        }