Exemplo 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;
            }
        }
Exemplo 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();
            }
        }
Exemplo 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();
            }
        }