public void ReplantSpruce(Tree[] trees)
        {
            Random random = new Random();
            bool   Diseased;
            bool   Protected;
            bool   Dove;

            if (random.Next(0, 10) == 0)
            {
                Diseased = true;
            }
            else
            {
                Diseased = false;
            }

            if (random.Next(0, 2) == 0)
            {
                Protected = true;
            }
            else
            {
                Protected = false;
            }

            if (random.Next(0, 50) == 0)
            {
                Dove = true;
            }
            else
            {
                Dove = false;
            }


            if (ReplantCount % 3 == 0)
            {
                trees[i] = new Maple(0, Diseased, Protected, Dove);
            }
            else
            {
                trees[i] = new Spruce(0, Diseased, Protected, Dove);
            }

            ReplantCount += 1;
        }
Example #2
0
        public Forest()
        {
            Random randint = new Random();
            int    RandomTree;
            int    RandomAge;
            int    RandomBool_asint;
            bool   Diseased;
            bool   Protection;
            bool   Dove;

            //makes 9999 trees
            for (int i = 0; i <= 9999; i++)
            {
                RandomTree = randint.Next(1, 6);

                //makes spruce trees
                if (RandomTree == 1)
                {
                    RandomAge = randint.Next(5, 201);

                    RandomBool_asint = randint.Next(0, 10);

                    if (RandomBool_asint == 0)
                    {
                        Diseased = true;
                    }
                    else
                    {
                        Diseased = false;
                    }

                    RandomBool_asint = randint.Next(0, 2);

                    if (RandomBool_asint == 0)
                    {
                        Protection = true;
                    }
                    else
                    {
                        Protection = false;
                    }

                    RandomBool_asint = randint.Next(0, 50);

                    if (RandomBool_asint == 0)
                    {
                        Dove = true;
                    }
                    else
                    {
                        Dove = false;
                    }

                    Trees[i] = new Spruce(RandomAge, Diseased, Protection, Dove);
                }
                //makes fir trees
                else
                {
                    RandomAge = randint.Next(50, 301);

                    RandomBool_asint = randint.Next(0, 2);

                    if (RandomBool_asint == 0)
                    {
                        Diseased = true;
                    }
                    else
                    {
                        Diseased = false;
                    }

                    if (RandomBool_asint == 0)
                    {
                        Protection = true;
                    }
                    else
                    {
                        Protection = false;
                    }

                    if (RandomBool_asint == 0)
                    {
                        Dove = true;
                    }
                    else
                    {
                        Dove = false;
                    }

                    Trees[i] = new Fir(RandomAge, Diseased, Protection, Dove);
                }
            }

            AllHarvested.Add(Trees[0]);
        }