Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Which continent you want to play?");
            string         continent = Console.ReadLine();
            IAnimalFactory factory   = new EuroFactory();

            if (continent == "Africa")
            {
                factory = new AfricaFactory();
            }
            ICarnivore carnivore = factory.GetCarnivore();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            ContinentFactory firstFactory = new AfricaFactory();
            Carnivore        firstAnimal  = firstFactory.CreateCarnivore();

            Console.WriteLine($"You could see {firstAnimal.GetType().Name} In Africa.");

            ContinentFactory secondFactory = new AmericaFactory();
            Carnivore        secondAnimal  = secondFactory.CreateCarnivore();

            Console.WriteLine($"You could see {secondAnimal.GetType().Name} In America.");

            Console.ReadLine();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Which contitnent do you want to play?");

            string contitnent = Console.ReadLine();

            IAnimalFactory factory = null;

            if (contitnent == "Africa")
            {
                factory = new AfricaFactory();
            }
            else if (contitnent == "Europe")
            {
                factory = new EuropeFactory();
            }

            ICarnivore animal = factory.GetCarnivore();
        }