Exemple #1
0
        public void OutputForest()
        {
            int spruce    = 0;
            int fir       = 0;
            int maple     = 0;
            int bug_hotel = 0;
            int dead      = 0;

            foreach (Tree tree in Trees)
            {
                string TreeType = Convert.ToString(tree.GetType());
                if (tree.GetDead() == true)
                {
                    dead += 1;
                }
                else if (tree is Spruce)
                {
                    spruce += 1;
                }
                else if (tree is Fir)
                {
                    fir += 1;
                }
                else if (tree is Maple)
                {
                    maple += 1;
                }
                else if (tree is BugHotel)
                {
                    bug_hotel += 1;
                }
            }

            Console.WriteLine("There are " + spruce + " Norway Spruce in the forest");
            Console.WriteLine("There are " + fir + " Nordmann Fir in the forest");
            Console.WriteLine("There are " + maple + " Maple Trees in the forest");
            Console.WriteLine("There are " + bug_hotel + " Bug Hotels in the forest");
            Console.WriteLine("There are " + dead + " dead trees in the forest");
            Console.WriteLine("There are " + WolfPack.GetCount() + " wolves in the forest");
            Console.WriteLine("There are " + DeerHerd.GetCount() + " deer in the forest");
            Console.WriteLine();

            int k = 0;

            for (int i = 0; i < 100; i++)
            {
                for (int j = 0; j < 100; j++)
                {
                    Trees[k].OutputTree();
                    k += 1;
                }

                Console.WriteLine();
            }

            Console.ReadLine();
        }
Exemple #2
0
        public bool Eat(Herd DeerHerd)
        {
            if (DeerHerd.GetCount() >= 12)
            {
                DeerHerd.Kill(0);
                return(true);
            }

            else
            {
                return(false);
            }
        }