예제 #1
0
        static void Main(string[] args)
        {
            Dog[] dogs = new Dog[]
            {
                new Dog("Pluto", 3, "male", "Pitbull"),
                new Dog("Zara", 4, "female", "American Bulldog"),
                new Dog("Codita", 6, "male", "Husky"),
                new Dog("Biskit", 4, "male", "Labrador"),
                new Dog("Suri", 8, "female", "Beagle"),
            };

            Cat[] cats = new Cat[]
            {
                new Cat("Garfield", 5, "male", "Fluffy"),
                new Cat("Lola", 3, "female", "Shorthair "),
                new Cat("Tina", 4, "female", "Longhair"),
                new Cat("Gigi", 7, "male", "Hairless")
            };

            Tomcats tom = new Tomcats("Gogu", 5, "male", "Fluffy");

            tom.MakeSound();
            Kittens kitten = new Kittens("Pisi", 1, "female", "Shorthair");

            kitten.MakeSound();

            Frog[] frogs = new Frog[]
            {
                new Frog("Kermit", 3, "male", "green"),
                new Frog("Pipa", 4, "female", "yellow"),
                new Frog("Mitz", 1, "male", "black"),
                new Frog("Bigboy", 9, "male", "white")
            };

            Console.WriteLine("=====================================");

            Console.WriteLine("Average age of dogs are: " + Dog.AverageAge(dogs));
            dogs[2].MakeSound();
            dogs[1].MakeSound();
            dogs[3].MakeSound();
            dogs[0].MakeSound();

            Console.WriteLine("=====================================");

            Console.WriteLine("Average age of cats are " + Cat.AverageAge(cats));
            cats[0].MakeSound();
            cats[3].MakeSound();
            tom.MakeSound();
            kitten.MakeSound();

            Console.WriteLine("=====================================");

            Console.WriteLine("Average age of frogs are: " + Frog.AverageAge(frogs));
            frogs[3].MakeSound();
            frogs[0].MakeSound();
            frogs[1].MakeSound();
            frogs[2].MakeSound();

            Console.WriteLine("=====================================");
        }
        public static void Main()
        {
            Cat[] cats = new Cat[]
            {
                new Cat("Jonny", 1, Sex.male),
                new Cat("Hue", 2, Sex.male),
                new Cat("Maia", 2, Sex.female),
            };

            Dog[] dogs = new Dog[]
            {
                new Dog("Ivo", 5, Sex.male),
                new Dog("Pesho", 4, Sex.male),
                new Dog("Maria", 8, Sex.female),
            };

            Frog[] frogs = new Frog[]
            {
                new Frog("Gosho", 4, Sex.male),
                new Frog("Ivan", 5, Sex.female),
                new Frog("Zahari", 3, Sex.male)
            };

            Kitten[] kittens = new Kitten[]
            {
                new Kitten("Mihaela", 5),
                new Kitten("Ivona", 3),
                new Kitten("Petra", 2)
            };

            Tomcat[] tomcats = new Tomcat[]
            {
                new Tomcat("Rado", 3),
                new Tomcat("Radoi", 3),
                new Tomcat("Frodo", 2)
            };

            Console.WriteLine("Cats average age is: ");
            Console.WriteLine("{0:F2}", Cat.AverageAge(cats));
            Console.WriteLine("The cat say: {0}", cats[0].Sound());
            Console.WriteLine();

            Console.WriteLine("Cats average age is: ");
            Console.WriteLine("{0:F2}", Dog.AverageAge(dogs));
            Console.WriteLine("The cat say: {0}", dogs[0].Sound());
            Console.WriteLine();

            Console.WriteLine("Cats average age is: ");
            Console.WriteLine("{0:F2}", Frog.AverageAge(frogs));
            Console.WriteLine("The cat say: {0}", frogs[0].Sound());
            Console.WriteLine();

            Console.WriteLine("Cats average age is: ");
            Console.WriteLine("{0:F2}", Kitten.AverageAge(kittens));
            Console.WriteLine("The cat say: {0}", kittens[0].Sound());
            Console.WriteLine();

            Console.WriteLine("Cats average age is: ");
            Console.WriteLine("{0:F2}", Tomcat.AverageAge(tomcats));
            Console.WriteLine("The cat say: {0}", tomcats[0].Sound());
        }