static void Main(string[] args) { //Шаблон проектирования, позволяющий изменять поведение системы, //варьируя создаваемые объекты, сохраняя при этом интерфейсы IContinentFactory africa = new AfricaFactory(); var world = new AnimalWorld(africa); Console.WriteLine(world.RunFoodChain()); IContinentFactory america = new AmericaFactory(); world = new AnimalWorld(america); Console.WriteLine(world.RunFoodChain()); Console.ReadKey(); }
public static void Main(string[] args) { // Create and run the African animal world ContinentFactory africa = new AfricaFactory(); AnimalWorld world = new AnimalWorld(africa); world.RunFoodChain(); // Create and run the American animal world ContinentFactory america = new AmericaFactory(); world = new AnimalWorld(america); world.RunFoodChain(); // Wait for user input Console.ReadKey(); }