Esempio n. 1
0
 public Grass(Savannah s,int x, int y)
 {
     weight = 6.0;
     posX = x;
     posY = y;
     this.s = s;
 }
Esempio n. 2
0
 // Creating reference to animals constructor to ease creating new objects
 public Lion(Savannah s, int x, int y)
     : base(s, x, y)
 {
     int gend = s.r.Next(0, 100);
     if (gend < 50)
         gender = false;
     else
     {
         gender = true;
     }
 }
Esempio n. 3
0
        public Form1()
        {
            InitializeComponent();
            savannah = new Savannah(pictureBox1, ran, ran2);
            savannah.godDraws();
            /*foreach (var animal in savannah.africa)
            {
                if (animal.ani != null)
                    Console.WriteLine(animal.ani.GetType());
            }

            for (int ikeepGoing = 0; ikeepGoing < 10; ikeepGoing++)
            {
                int counter = 0;

                for (int i = 0; i < 20; i++)
                {
                    for (int j = 0; j < 20; j++)
                    {
                        //Creating a Console App to test and see if the objects are in fact created
                        if (savannah.africa[i, j].ani is Rabbit)
                        {
                            Console.Write("R ");
                        }
                        if (savannah.africa[i, j].ani is Lion)
                        {
                            Console.Write("L ");
                            savannah.africa[i,j].ani.move();
                        }
                        if (savannah.africa[i, j].ani == null && savannah.africa[i, j].grass == null)
                        {
                            Console.Write("  ");
                        }
                        if (savannah.africa[i, j].grass != null)
                        {
                            Console.Write("G ");
                            savannah.africa[i, j].grass.grow();
                            counter = counter + 1;

                        }
                    }
                    Console.WriteLine("|");
                }
                Console.WriteLine("----------------------------------------/");
                Console.WriteLine("There is {0} amount of grass", counter);
            }
            //Sleep is made to test if the objects does in fact move
                Thread.Sleep(1000);*/
        }
Esempio n. 4
0
        protected Animals(Savannah s, int x, int y)
        {
            this.s = s;
            posX = x;
            posY = y;

            if (s.africa[posX, posY].ani is Rabbit)
            {
                weight = s.r.Next(7,10);
            }
            else if (s.africa[posX,posY].ani is Lion)
            {
                weight = s.r2.Next(40, 60);
            }
            if (s.africa[posX, posY].ani == null)
            {

            }
        }