Exemplo n.º 1
0
        public void Generate(int x, int y, int z, int chunksize)
        {
            List <Tree> treelist = new List <Tree>();

            if (args.OPERATION == Operation.Conserve)
            {
                FindTrees(treelist, x, y, z, chunksize);
            }

            if (args.TREECOUNT > 0 && treelist.Count > args.TREECOUNT)
            {
                treelist = new List <Tree>(MyLinq.Take(treelist, args.TREECOUNT));
            }

            if (args.OPERATION == Operation.Replant || args.OPERATION == Operation.Add)
            {
                switch (args.SHAPE)
                {
                case TreeShape.Rainforest:
                    PlantRainForestTrees(treelist, x, y, z, chunksize);
                    break;

                case TreeShape.Mangrove:
                    PlantMangroves(treelist, x, y, z, chunksize);
                    break;

                default:
                    PlantTrees(treelist, x, y, z, chunksize);
                    break;
                }
            }

            if (args.OPERATION != Operation.ClearCut)
            {
                ProcessTrees(treelist);
                if (args.FOLIAGE)
                {
                    foreach (Tree tree in treelist)
                    {
                        tree.MakeFoliage();
                    }
                }
                if (args.WOOD)
                {
                    foreach (Tree tree in treelist)
                    {
                        tree.MakeTrunk();
                    }
                }
            }
        }
        public static void Video4_9_Querying_Infinity_Start()
        {
            Console.WriteLine("");
            Console.WriteLine("Video4_9_Querying_Infinity");
            Console.WriteLine("---------------------------------------------");
            Console.WriteLine("");

            var numbers = MyLinq.Random().Where(n => n > 0.5).Take(10);

            foreach (var number in numbers)
            {
                Console.WriteLine(number);
            }
        }
Exemplo n.º 3
0
        public void small_linq()
        {
            var ll = new List <string>()
            {
                "S1", "S2"
            };

            if (ll.Count() > 0)
            {
                //...
            }

            var onlyOne = MyLinq.Where(ll, s => s[0] == '1');
            var inInt   = MyLinq.Select(onlyOne, x => int.Parse(x));

            var theMax = ll.Where(s => s[0] == '1')
                         .Select(x => int.Parse(x))
                         .Max();
        }