예제 #1
0
        static void Main(string[] args)
        {
            var belarus = new BelarusFactory();
            var world   = new AnimalWorld(belarus);

            world.RunFoodChain();
        }
예제 #2
0
        static void Main(string[] args)
        {
            string continent = "";

            if (args.Length >= 1)
            {
                continent = args[0]; //properties of the project >> Debug >> Aplication Arguments
            }

            //here we can see that the class (AnimalWorld) has private constructor
            IContinentFactory myContinent1 = AnimalWorld.CreateContinent(continent);  //factory

            ICarnivore myCarnivore1 = myContinent1.CreateCarnivore();                 //factory
            IHebivore  myHarbivore1 = myContinent1.CreateHerbivore();

            myCarnivore1.Hunt();
            myHarbivore1.Graze();

            Console.WriteLine(myCarnivore1.GetType().FullName);


            //Console.WriteLine("Choose continent");
            //string continent = "america";
            //Console.WriteLine("Choose continent");
            //string continent2 = Console.ReadLine();
            //var myContinent2 = AnimalWorld.CreateContinent(continent2);
            //var myC2 = myContinent2.CreateCarnivore();
            //myC2.Hunt();

            Console.ReadKey();
        }
예제 #3
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();
        }
예제 #4
0
        static void Main(string[] args)
        {
            AnimalWorld AfricaWorld = new AnimalWorld();

            AfricaWorld.AnimalWorldFactory = new Africa();

            Herbivore herbivore = AfricaWorld.CreatHerbivores();
            Carnivore carnivore = AfricaWorld.CreatCarnivores();
        }
예제 #5
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();
        }
예제 #6
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();
        }
예제 #7
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);
        }
예제 #8
0
        static void Main(string[] args)
        {
            var africa = new AnimalWorld <Africa>();

            africa.RunFoodChain();

            var america = new AnimalWorld <America>();

            america.RunFoodChain();

            Console.ReadKey();
        }
예제 #9
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();
        }
예제 #10
0
 static void Main(string[] args)
 {
     AnimalWorld.Herbivores.AddLast(new Gnu());
     AnimalWorld.Herbivores.AddFirst(new Bison());
     AnimalWorld.Carnivores.AddLast(new Lion());
     AnimalWorld.Carnivores.AddFirst(new Wolf());
     AnimalWorld.MealHerbivore();
     foreach (var item in AnimalWorld.Herbivores)
     {
         Console.WriteLine(item.Height);
     }
     AnimalWorld.MealCarnivore();
 }
예제 #11
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();
        }
        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();
        }
예제 #13
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();
        }
예제 #14
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();
        }
예제 #15
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();
        }
예제 #16
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();
        }
        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
             */
        }
예제 #18
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();
        }
예제 #19
0
        static void Main(string[] args)
        {
            ContinentFactory afrFactory = new AfricanFactory();
            ContinentFactory americanFactory = new AmericanFactory();

            AnimalWorld animalWorld = new AnimalWorld(afrFactory);
            animalWorld.FoodChain();

            AnimalWorld animal2World = new AnimalWorld(americanFactory);
            animal2World.FoodChain();

            Console.ReadKey();
        }