Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            // Cat rex = new Cat("rex", 3, 7.5,40);
            // rex.eat();
            // rex.say();
            //
            // Ciamoi caat = new Ciamoi("caat", 4, 2,45,45);
            // caat.say();
            Animals cat = new Animals("Catss", 2, 5, 45);

            Console.WriteLine(cat.name);
            Console.WriteLine(cat.age);

            //    Can't Access neither Protected nor Private
            // Console.WriteLine(cat.weight);
            // Console.WriteLine(cat.leength);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Animals animal = new Animals();

            animal.AddMammal("Hippopotamus", true);
            animal.AddMammal("Lion", true);
            animal.AddMammal("Zebra", true);
            animal.AddMammal("Cheetah", true);
            animal.AddMammal("Giraffe", true);
            animal.AddPrimate("Baboon", true);
            animal.AddPrimate("Chimpanzee", true);
            animal.AddPrimate("Gorilla", false);
            animal.AddReptile("Crocodile", true);
            animal.AddReptile("Snakes", false);
            animal.AddReptile("Lizard", true);

            foreach (string name in animal.Mammal)
            {
                Console.WriteLine(name + " ");
            }

            Console.WriteLine();

            foreach (string name in animal.Primate)
            {
                Console.WriteLine(name + " ");
            }

            Console.WriteLine();

            foreach (string name in animal.Reptile)
            {
                Console.WriteLine(name + " ");
            }

            Console.WriteLine();

            Console.ReadKey();
        }
Exemplo n.º 3
0
        public void Process(Animals form)
        {
            int currentNOfFishes = NumberOfFishes, currentNOfBirds = NumberOfBirds, currentNOfMammals = NumberOfMammals;

            while (true)
            {
                Thread.Sleep(200);

                for (int i = 0; i < currentNOfFishes && i < NumberOfFishes; i++)
                {
                    fishes.ElementAt(i).Live();
                    form.Draw();
                }

                for (int i = 0; i < currentNOfBirds && i < NumberOfBirds; i++)
                {
                    birds.ElementAt(i).Live();
                    form.Draw();
                }

                for (int i = 0; i < currentNOfMammals && i < NumberOfMammals; i++)
                {
                    mammals.ElementAt(i).Live();
                    form.Draw();
                }

                AddFood();

                currentNOfFishes  = NumberOfFishes;
                currentNOfBirds   = NumberOfBirds;
                currentNOfMammals = NumberOfMammals;

                if (NumberOfFishes == 0 && NumberOfBirds == 0 && NumberOfMammals == 0)
                {
                    form.Draw(); return;
                }
            }
        }