Exemplo n.º 1
0
        static void Main()
        {
            /*
             * Structural
             */

            StructuralAbstractFactory factory1 = new ConcreteFactory1();
            Client client1 = new Client(factory1);

            client1.Run();

            StructuralAbstractFactory factory2 = new ConcreteFactory2();
            Client client2 = new Client(factory2);

            client2.Run();

            /*
             * Real World
             */

            AfricaFactory africa = new AfricaFactory();
            AnimalWorld   world  = new AnimalWorld(africa);

            world.RunFoodChain();

            RealWorldAbstractFactory america = new AmericaFactory();

            world = new AnimalWorld(america);
            world.RunFoodChain();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            ContinentFactory asia = new AsiaFactory();
            AnimalWorld world = new AnimalWorld(asia);
            world.RunFoodChain();

            ContinentFactory america = new AmericaFactory();
            world = new AnimalWorld(america);
            world.RunFoodChain();
        }
        public void RunExample2()
        {
            ContinentFactory africaFactory  = new AfricaFactory();
            ContinentFactory americaFactory = new AmericaFactory();
            AnimaWorld       animaWorld     = new AnimaWorld(africaFactory);

            animaWorld.RunAnimaWorld();
            animaWorld.ChangeFactory(americaFactory);
            animaWorld.RunAnimaWorld();
        }
Exemplo n.º 4
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();
        }
Exemplo n.º 5
0
        /// Entry point into console application.



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



            int  unOps = 5;
            int  preIncrement;
            int  preDecrement;
            int  postIncrement;
            int  postDecrement;
            int  positive;
            int  negative;
            bool temp;

            preIncrement = ++unOps;
            Console.WriteLine("pre-Increment: {0}", preIncrement);

            preDecrement = --unOps;
            Console.WriteLine("pre-Decrement: {0}", preDecrement);

            postDecrement = unOps--;
            Console.WriteLine("Post-Decrement: {0}", postDecrement);

            postIncrement = unOps++;
            Console.WriteLine("Post-Increment: {0}", postIncrement);

            Console.WriteLine("Final Value of unOps is: {0}", unOps);

            positive = +postIncrement;
            Console.WriteLine("Positive: {0}", positive);

            negative = -postIncrement;
            Console.WriteLine("Negative: {0}", negative);

            temp = false;
            temp = !temp;
            Console.WriteLine("Logical Not: {0}", temp);
        }
Exemplo n.º 6
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();
        }
Exemplo n.º 7
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();
        }
Exemplo n.º 8
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();
        }
Exemplo n.º 10
0
        public static IContinentFactory CreateContinent(string continet)
        {
            IContinentFactory cf;

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

            return(cf);
        }
Exemplo n.º 11
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();
        }
Exemplo n.º 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();
        }
Exemplo n.º 13
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();
        }
Exemplo n.º 14
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
             */
        }
Exemplo n.º 16
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();
        }