Exemplo n.º 1
0
        static void Main()
        {
            Dog kuche = new Dog("Kudjo", "Male", 12);

            kuche.ProduceSound();

            Dog[] dogs = new Dog[]
            {
                new Dog("Dog1", "Male", 12),
                new Dog("Dog2", "Male", 5),
                new Dog("Dog3", "Male", 5),
                new Dog("Dog4", "Male", 6),
                new Dog("Dog5", "Male", 8),
            };
            int avgYearsDogs = Animal.AvgAge(dogs);

            Tomcat[] cats = new Tomcat[]
            {
                new Tomcat("cat1", "Male", 12),
                new Tomcat("cat2", "Male", 11),
                new Tomcat("cat3", "Male", 2),
                new Tomcat("cat4", "Male", 5),
                new Tomcat("cat5", "Male", 7),
                new Tomcat("cat6", "Male", 18),
            };
            int avg = Animal.AvgAge(cats);

            Console.WriteLine("Dog average age: {0}", avgYearsDogs);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            List <Animal> listDog = new List <Animal>
            {
                new Dog(2, "A", "Mail"),
                new Dog(3, "B", "Mail"),
                new Dog(1.5, "C", "FMail"),
                new Dog(2.5, "D", "FMail"),
            };
            double avgAg = Animal.AvgAge(listDog);

            Console.WriteLine(avgAg);
        }