示例#1
0
        static void Main(string[] args)
        {
            ContinentFactory myContinentFactory = new AfricaFactory();
            AnimalWorld myAnimalWorld = new AnimalWorld(myContinentFactory);
            myAnimalWorld.RunFoodChain();

            myContinentFactory = new AmericaFactory();
            myAnimalWorld = new AnimalWorld(myContinentFactory);
            myAnimalWorld.RunFoodChain();
        }
示例#2
0
        static void Main(string[] args)
        {
            ContinentFactory africa = new AfricaFactory();
            AnimalWorld world = new AnimalWorld(africa);
            world.RunFoodChain();

            ContinentFactory america = new AmericaFactory();
            world = new AnimalWorld(america);
            world.RunFoodChain();

            Console.ReadKey();
        }
示例#3
0
        public static void Main()
        {
            ContinentFactory africa = new AfricaFactory();
            AnimalWorld      world  = new AnimalWorld(africa);

            world.RunFoodChain();

            ContinentFactory america = new AmericaFactory();

            world = new AnimalWorld(america);
            world.RunFoodChain();

            Console.ReadKey();
        }
示例#4
0
        static void Main(string[] args)
        {
            ContinentFactory africa = new AfricaFactory();
            AnimalWorld      world  = new AnimalWorld(africa);

            world.RunFood();

            ContinentFactory america = new AmericaFactory();

            world = new AnimalWorld(america);
            world.RunFood();

            Console.ReadKey();
        }
        public void Main()
        {
            // Create and run the African animal world
            IContinentFactory africa = new AfricaFactory();
            var world = new AnimalWorld(africa);

            world.RunFoodChain();

            // Create and run the American animal world
            IContinentFactory america = new AmericaFactory();

            world = new AnimalWorld(america);
            world.RunFoodChain();
        }
示例#6
0
        public static IContinentFactory CreateContinent(string continet)
        {
            IContinentFactory cf;

            if (continet.ToLower().Trim() == "america")
            {
                cf = new AmericaFactory();
            }
            else
            {
                cf = new AfricaFactory();
            }

            return(cf);
        }
示例#7
0
        static void Main(string[] args)
        {
            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();
            Console.ReadKey();
        }
示例#8
0
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        public static void Main()
        {
            // 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();
        }
示例#9
0
        static void Main(string[] args)
        {
            Console.WriteLine("Animales concretos de africa");
            IContinentFactory africa        = new AfricaFactory();
            AnimalWorld       clienteAfrica = new AnimalWorld(africa);

            clienteAfrica.RunFoodChain();

            Console.WriteLine("Animales concretos de america");
            IContinentFactory america        = new AmericaFactory();
            AnimalWorld       clienteAmerica = new AnimalWorld(america);

            clienteAmerica.RunFoodChain();

            Console.ReadKey();
        }
示例#10
0
        static void Main(string[] args)
        {
            // Create and run the African animal world
            ContinentFactory  africa = new AfricaFactory();
            AnimalWorldClient world  = new AnimalWorldClient(africa);

            world.RunFoodChain();

            // Create and run the American animal world
            ContinentFactory america = new AmericaFactory();

            world = new AnimalWorldClient(america);
            world.RunFoodChain();

            // Wait for user input
            Console.Read();
        }
        public static void Run()
        {
            Console.WriteLine("This real-world code demonstrates the creation of different animal worlds for a computer game using different factories. Although the animals created by the Continent factories are different, the interactions among the animals remain the same.");
            ContinentFactory africa = new AfricaFactory();
            AnimalWorld      world  = new AnimalWorld(africa);

            world.RunFoodChain();

            ContinentFactory america = new AmericaFactory();

            world = new AnimalWorld(america);
            world.RunFoodChain();

            /*
             * Lion eats Wildebeest
             * Wolf eats Bison
             */
        }
示例#12
0
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        public static void Main()
        {
            // 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();
        }