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(); }
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(); }
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(); }