Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Animal[] zoo = new Animal[3];
            zoo[0] = new Lion("bobby", "lion", 4, 2);
            zoo[1] = new Fish("bobbert", "fish two", 14, 21);
            zoo[2] = new Eagle("bob", "eagle", 1, 0);
            int i;

            for (i = 0; i < zoo.Length; i++)
            {
                zoo[i].Speak;
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Animal[] Zoo = new Animal[3];
            Zoo[0] = new Lion("Lion", "Simba", 2, 3);
            Zoo[1] = new Fish("Blue Tang", "Dory", 2, 5);
            Zoo[2] = new Eagle("Bald Eagle", "Beep", 2, 2);

            Lion Leo = (Lion)Zoo[0];


            for (int i = 0; i < Zoo.Length; i++)
            {
                Zoo[i].Speak();
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Animal[] Zoo = new Animal[3];
            Zoo[0] = new Lion("Actual Lion", 10, 4);
            Lion ActualLion = (Lion)Zoo[0];

            Zoo[1] = new Fish("Actual Fish", 10, 10);
            Zoo[2] = new Eagle("Actual Eagle", 10, 2);

            for (int i = 0; i < Zoo.Length; i += 1)
            {
                Console.WriteLine("{0} {1}", Zoo[i].GetName(), Zoo[i].GetAge());
                Zoo[i].Speak();
            }
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            Animal[] animals = new Animal[]
            {
                new Lion("Larry", "Indian", 45, 4),
                new Fish("Fishhy", "Shark", 5, 0),
                new Eagle("Tom", "Bird", 9, 0)
            };

            Lion Larry = (Lion)animals[0];

            Larry.run();

            Fish Fishhy = (Fish)animals[1];

            Fishhy.swim();

            for (int i = 0; i < animals.Length; i++)
            {
                Console.WriteLine(animals[i].GetName());
                animals[i].Speak();
            }
        }