Exemple #1
0
        static void Main()
        {
            // Create arrays of different kinds of animals and calculate the average age of each kind of animal using a static method (you may use LINQ).
            List <Animal> animals = new List <Animal>();

            animals.Add(new Cat("Garfield", 5, Gender.Male));
            animals.Add(new Dog("Scooby Doo", 8, Gender.Male));
            animals.Add(new Frog("Mr. Toad", 2, Gender.Female));
            animals.Add(new Kitten("IWatchYouSleepAtNight", 3));
            animals.Add(new Tomcat("Tom", 5));
            animals.Add(new Cat("Pisana", 8, Gender.Female));
            animals.Add(new Dog("Mark", 4, Gender.Male));
            animals.Add(new Frog("Froggy", 2, Gender.Male));
            animals.Add(new Kitten("HoomanSlaya", 0));
            animals.Add(new Tomcat("PussInBoots", 3));
            animals.Add(new Cat("Pesho", 3, Gender.Male));
            animals.Add(new Dog("Sharo", 5, Gender.Male));
            animals.Add(new Frog("Kwak", 9, Gender.Female));
            animals.Add(new Kitten("DreamCrusher", 10));
            animals.Add(new Tomcat("Kotio", 9));

            var dogs    = animals.Where(d => d is Dog);
            var frogs   = animals.Where(f => f is Frog);
            var cats    = animals.Where(c => c is Cat);
            var tomcats = animals.Where(t => t is Tomcat);
            var kittens = animals.Where(k => k is Kitten);

            Console.WriteLine($"Dogs' average age is: {Dog.CalculateAverageAge(dogs)}");
            Console.WriteLine($"Frogs' average age is: {Frog.CalculateAverageAge(frogs)}");
            Console.WriteLine($"Cats' average age is: {Cat.CalculateAverageAge(cats)}");
            Console.WriteLine($"Tomcats' average age is: {Tomcat.CalculateAverageAge(tomcats)}");
            Console.WriteLine($"Kittens' average age is: {Kitten.CalculateAverageAge(kittens)}");
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Kitten kit   = new Kitten("Kitty", 2);
            Tomcat tom   = new Tomcat("Tom", 3);
            Frog   leggy = new Frog("Leggy", 6, Gender.Male);
            Dog    rex   = new Dog("Rex", 4, Gender.Male);
            Cat    snow  = new Cat("Snow", 5, Gender.Female);

            List <Animal> animals = new List <Animal>()
            {
                kit, tom, leggy, rex, snow
            };

            IntroduceAnimal(animals);

            Kitten[] kittens = new Kitten[] { kit, new Kitten("Lilly", 1), new Kitten("Smurf", 2) };
            Tomcat[] tomcats = new Tomcat[] { tom, new Tomcat("Joefrrey", 3), new Tomcat("Steve", 2), new Tomcat("Paul", 1) };
            Frog[]   frogs   = new Frog[] { leggy, new Frog("Squirrle", 12, Gender.Female), new Frog("Kurt", 1, Gender.Male) };
            Dog[]    dogs    = new Dog[] { rex, new Dog("Fluffy", 4, Gender.Female), new Dog("Olde Doge", 12, Gender.Male) };
            Cat[]    cats    = new Cat[] { snow };

            Console.WriteLine("Kittens: {0:F2}", Animal.AverageAge(kittens));
            Console.WriteLine("Tomcats: {0:F2}", Animal.AverageAge(tomcats));
            Console.WriteLine("Frogs: {0:F2}", Animal.AverageAge(frogs));
            Console.WriteLine("Dogs: {0:F2}", Animal.AverageAge(dogs));
            Console.WriteLine("Cats: {0:F2}", Animal.AverageAge(cats));
        }
Exemple #3
0
        static void Main(string[] args)
        {
            var myJaba   = new Frog("Jaba The Hut", 3, Gender.Male, Frog.FrogBreed.Julta);
            var myKotka  = new Cat("Ruski Bradar", 4, Gender.Male, Cat.CatBreed.Egyptian);
            var myTomCat = new Tomcat("Ma Kotka", 2, Cat.CatBreed.Persian);

            Animal[] myAnimals = new Animal[] { myTomCat, myJaba, myKotka };

            Console.WriteLine(myAnimals.AverageAge());
        }
Exemple #4
0
        static void Main(string[] args)
        {
            // new Tomcat(12, "").MakeSound();
            // new Kitten(12, "").MakeSound();

            Animal animal1  = new Cat(5, "Kaloianka", Sex.Female);
            Animal animal2  = new Cat(10, "Evgeniq", Sex.Female);
            Animal animal3  = new Cat(9, "Pesho", Sex.Male);
            Animal animal4  = new Frog(12, "Stavri", Sex.Male);
            Animal animal5  = new Frog(2, "Petka", Sex.Female);
            Animal animal6  = new Dog(3, "Nikoleta", Sex.Female);
            Animal animal7  = new Dog(42, "OldDog", Sex.Male);
            Animal animal8  = new Dog(3, "Harry", Sex.Male);
            Animal animal9  = new Kitten(12, "Stanka");
            Animal animal10 = new Kitten(3, "Petranka");
            Animal animal11 = new Kitten(2, "Nakovka");
            Animal animal12 = new Tomcat(4, "Tom");
            Animal animal13 = new Tomcat(6, "Thomas");
            Animal animal14 = new Tomcat(7, "Tommy");
            Animal animal15 = new Tomcat(2, "Toma");

            Animal[] animalKingdom = new []
            {
                animal1,
                animal2,
                animal3,
                animal4,
                animal5,
                animal6,
                animal7,
                animal8,
                animal9,
                animal10,
                animal11,
                animal12,
                animal13,
                animal14,
                animal15
            };

            var results = animalKingdom
                          .GroupBy(an => an.GetType())
                          .Select(g => new
            {
                Average = g.Average(a => a.Age),
                g.Key
            });

            foreach (var result in results)
            {
                Console.Write(result.Key);
                Console.Write(": Average age ");
                Console.WriteLine(result.Average);
            }
        }
        static void Main()
        {
            string[] names = new string[]
            {
                "CALVIN",
                "CALYPSO",
                "CALZE",
                "FANCY",
                "FANNY",
                "FANTASIA",
                "MADDIE",
                "MADEIRA",
                "MADISON",
                "MADMAX",
                "FROGY"
            };
            Random rand = new Random();

            Animal[] cats = new Cat[12];
            for (int i = 0; i < cats.Length; i++)
            {
                string name = names[rand.Next(0, 10)];
                uint age = (uint)rand.Next(1, 10);
                SexType sex = (SexType)rand.Next(1, 3);
                Cat cat = new Cat(name, age);
                cat.Sex = sex;
                cats[i] = cat;
            }
            cats[10] = new Kitten("Kity", 1);
            cats[11] = new Tomcat("Big", 3);

            uint catsAverageAge = Animal.CalculateAverageAge(cats);
            Console.WriteLine("Cats average age: {0}" , catsAverageAge);

            Animal[] frogs = new Frog[3];
            for (int i = 0; i < frogs.Length; i++)
            {
                string name = names[rand.Next(8, 11)];
                uint age = (uint)rand.Next(1, 5);
                SexType sex = (SexType)rand.Next(1, 3);
                Frog frog = new Frog(name, age);
                frog.Sex = sex;
                frogs[i] = frog;
            }

            Console.WriteLine("Frogs make sound");
            foreach (var frog in frogs)
            {
                frog.MakeSound();
                Console.WriteLine("Wait");
            }
        }
Exemple #6
0
        public static void ShowAnimals()
        {
            Frog myFrog1 = new Frog("broscuta2", 2, SexOfAnimal.Male, "doar saritoare");
            Frog myFrog2 = new Frog("broscuta3", 3, SexOfAnimal.Female);
            Frog myFrog3 = new Frog("broscuta4", 4);

            Frog[] frogs = new Frog[] { myFrog1, myFrog2, myFrog3 };

            Dog[] dogs = new Dog[]
            {
                new Dog("Rex", 12, SexOfAnimal.Male, "bulldog"),
                new Dog("Giant", 1, SexOfAnimal.Female, "pudel"),
                new Dog("Cutu", 3, SexOfAnimal.Male, "ciobanesc"),
                new Dog("Cutu Schiop", 3, SexOfAnimal.Male),
                new Dog("Wolfy", 5),
            };

            Cat cat1 = new Cat("Miti", 5, SexOfAnimal.Female, "negru");
            Cat cat2 = new Cat("Boss", 6, SexOfAnimal.Male);
            Cat cat3 = new Cat("Mya", 4);

            Cat[] cats = new Cat[] { cat1, cat2, cat3 };

            Tomcat[] tomcats = new Tomcat[]
            {
                new Tomcat("Tom1", 5, SexOfAnimal.Male, "albastru"),
                new Tomcat("Tom2", 8, SexOfAnimal.Female),
                new Tomcat("Tom3", 17)
            };

            Kitten[] kittens = new Kitten[]
            {
                new Kitten("kitty1", 20, SexOfAnimal.Male, "alb"),
                new Kitten("kitty2", 10, SexOfAnimal.Male),
                new Kitten("kitty3", 15)
            };

            Console.WriteLine(" - " + Animal.calculateAverageAge(kittens));

            List <Animal[]> listaZoo = new List <Animal[]>()
            {
                frogs, dogs, cats, tomcats, kittens
            };

            foreach (var animalzoo in listaZoo)
            {
                Animal.PrintAnimals(animalzoo);
            }
        }
        static void Main()
        {
            //Create arrays of different kinds of animals
            Animal[] animals = new Animal[5];
            animals[0] = new Kitten("Kitty", 1);
            animals[1] = new Tomcat("Tom", 5);
            animals[2] = new Frog("Froggy");
            animals[3] = new Frog("granny Frog", 6, Sex.Female);
            animals[4] = new Dog("Balkan", 4, Sex.Male);

            //test sound
            Console.WriteLine("Test sounds:");
            Console.WriteLine();

            foreach (var item in animals)
            {
                Console.WriteLine(item);
                Console.WriteLine(item.ProduceSound());
            }
            Console.WriteLine();

            //and calculate the average age of each kind of animal using a static method (you may use LINQ).

            var animalsAverageAgeByType = animals.GroupBy(a => a.GetType().Name)
                .Select(g => new { Kind = g.Key, AverageAge = g.Average(item => item.Age) });

            Console.WriteLine("Average age of each kind of animal using a static method");

            foreach (var item in animalsAverageAgeByType)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine();

            var animalsAverageAgeByTypeLINQ =
                from a in animals
                group a by a.GetType().Name into k
                select new { Kind = k.Key, AverageAge = k.Average(a => a.Age) };

            Console.WriteLine("Average age of each kind of animal using LINQ");

            foreach (var item in animalsAverageAgeByTypeLINQ)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine();
        }
        static void Main()
        {
            Kitten penka = new Kitten("Penka", 1);
            Tomcat gosho = new Tomcat("Gosho", 5);
            Frog stamat = new Frog("Stamat", 1, AnimalGender.Male);
            Dog sharo = new Dog("Sharo", 15, AnimalGender.Male);
            Cat pisana = new Cat("Pisana", 3, AnimalGender.Female);

            List<Animal> animals = new List<Animal>() { penka, gosho, stamat, sharo, pisana };

            foreach (var animal in animals)
            {
                Console.WriteLine(animal.ToString());
            }
            Console.WriteLine(Animal.CalculateAverageAge(animals));
        }
Exemple #9
0
        static void Main()
        {
            Dog[] dogs = new Dog[]
            {
                new Dog("Balkan", 2, "male", "ulichna"),
                new Dog("Pesho", 2, "male", "pincher"),
                new Dog("Rexy", 1, "male", "Deutscher Schäferhund")
            };

            Cat[] cats = new Cat[]
            {
                new Cat("Maca", 3, "female", "siamka"),
                new Cat("Pena", 2, "female", "persiika"),
                new Cat("Minka", 1, "female", "siamka")
            };

            Tomcat tom   = new Tomcat("Tom", 2, "male", "wow");
            Kitten kitty = new Kitten("Asya", 2, "female", "Little kitty");

            Frog[] frogs = new Frog[]
            {
                new Frog("Jabcho", 3, "male", "Green frog"),
                new Frog("Pesho", 2, "male", "Red frog"),
                new Frog("Minka", 1, "female", "Pink frog")
            };

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

            Console.WriteLine();

            Console.WriteLine("Average age of cats are: " + Cat.CalculateAverageAge(cats));
            cats[0].Sound();
            cats[1].Sound();
            cats[2].Sound();

            Console.WriteLine();

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

            Console.WriteLine();
        }
        static void Main()
        {
            var miro = new Cat("Miro", 4, true);

            miro.Sound();
            var suke = new Kitten("Sukke", 4, true);

            suke.Sound();
            Console.WriteLine(suke.Sex);
            var ivko = new Tomcat("Ivko", 7, true);

            ivko.Sound();
            Console.WriteLine(ivko.Name + " " + ivko.Age);

            Console.WriteLine("My name is {0}, I,m {1} old {2} cat", suke.Name, suke.Age, suke.Sex?"male":"female");
            Console.WriteLine("My name is {0}, I,m {1} old {2} cat", ivko.Name, ivko.Age, ivko.Sex?"male":"female");
        }
        static void Main(string[] args)
        {
            Frog frog1 = new Frog();

            frog1.name = "Erica";
            frog1.age  = 25;
            frog1.sex  = Sex.Female;
            Console.WriteLine(frog1.name);
            Console.WriteLine(frog1.sex);
            Console.WriteLine(frog1.age);

            Console.WriteLine("------------");

            Frog frog2 = new Frog("Paul", 27, Sex.Male);

            Console.WriteLine(frog2.name);
            Console.WriteLine(frog2.sex);
            Console.WriteLine(frog2.age);

            Cat cat1 = new Cat("Tom", 8, Sex.Male);

            Console.WriteLine(cat1.name);
            Console.WriteLine(cat1.age);
            Console.WriteLine(cat1.sex);



            Kitten kitten1 = new Kitten("Lili", 1);

            Console.WriteLine(kitten1.name);
            Console.WriteLine(kitten1.age);
            Console.WriteLine(kitten1.sex);

            Console.WriteLine("*************");

            Tomcat tomcat1 = new Tomcat("Alfred", 2);

            Console.WriteLine(tomcat1.name);
            Console.WriteLine(tomcat1.age);
            Console.WriteLine(tomcat1.sex)

            Animal[] animals = new Animal {
                frog1, frog2,
            }
        }
Exemple #12
0
        static void Main(string[] args)
        {
            IAnimal[] dogs = new Dog[] { new Dog("Roki", 13), new Dog("Lassie", 5), new Dog("Kiro", 10)
                                         , new Dog("Miro", 6), new Dog("Lucky", 7) };
            Console.WriteLine("Average age (Dogs): {0}", dogs.Sum(dog => dog.Age) / (decimal)dogs.Length);

            IAnimal[] frogs = new Frog[] { new Frog("Franklin", 13), new Frog("Lilly", 5), new Frog("Smiley", 10)
                                           , new Frog("Johnny", 6), new Frog("Daisy", 7) };
            Console.WriteLine("Average age (Frogs): {0}", frogs.Sum(frog => frog.Age) / (decimal)frogs.Length);

            IAnimal[] kittens = new Kitten[] { new Kitten("Ema", 13), new Kitten("Princes", 5), new Kitten("Chera", 10)
                                               , new Kitten("Tweety", 6), new Kitten("Puppy", 7) };
            Console.WriteLine("Average age (Kittens): {0}", kittens.Sum(kitty => kitty.Age) / (decimal)kittens.Length);

            IAnimal[] tomcats = new Tomcat[] { new Tomcat("Serafim", 13), new Tomcat("Garfield", 5), new Tomcat("Johhny", 10)
                                               , new Tomcat("Steve", 6), new Tomcat("Rijo", 7) };
            Console.WriteLine("Average age (Tomcats): {0}", tomcats.Sum(tomcat => tomcat.Age) / (decimal)tomcats.Length);
        }
        static void Main(string[] args)
        {
            Dog[] dogs = new Dog[]
            {
                new Dog("Sharo",5,'F'),
                new Dog("Mimi",3,'M'),
                new Dog("Becks",3.4,'F')
            };
            Frog[] frogs = new Frog[]
            {
                new Frog("BiBI", 13, 'F'),
                new Frog("Katya", 15, 'M'),
                new Frog("Kolio", 5, 'M'),
                new Frog("Niki", 10, 'M')
            };

            Cat[] cats = new Cat[]
            {
                new Cat("Ass", 3, 'F'),
                new Cat("Hand", 5, 'F'),
                new Cat("Head", 1, 'F'),
                new Cat("Leg", 7, 'M')
            };

            Kitten[] kittens = new Kitten[]
            {
                new Kitten("Malcho", 1),
                new Kitten("Palcho", 2),
                new Kitten("Shalco", 1)

            };

            Tomcat[] tomcats = new Tomcat[]
            {
                new Tomcat("Gosho", 5),
                new Tomcat("Mitko", 4),
                new Tomcat("Pesho", 8)
            };
            Console.WriteLine("Average age of the dogs: {0:F2}", Animal.AverageAge(dogs));
            Console.WriteLine("Average age of the frogs: {0:F2}",Animal.AverageAge(frogs));
            Console.WriteLine("Average age of the cats: {0:F2}",Animal.AverageAge(cats));
            Console.WriteLine("Average age of the kittens: {0:F2}", Animal.AverageAge(kittens));
            Console.WriteLine("Average age of the tomcats: {0:F2}",Animal.AverageAge(tomcats));
        }
Exemple #14
0
        static void Main()
        {
            ISound frog = new Frog(1, "Fro", "female");

            frog.Sound();

            ISound kiti = new Kitten(1, "kiti");

            kiti.Sound();

            ISound tom = new Tomcat(7, "Tom");

            tom.Sound();

            Animals[] animals1 =
            {
                new Dog(5,    "Rex",    "male"),
                new Frog(1,   "Fro",    "female"),
                new Cat(3,    "Sisi",   "female"),
                new Dog(3,    "Mimi",   "female"),
                new Frog(2,   "Orf",    "male"),
                new Tomcat(5, "Tomas"),
                new Kitten(2, "Fifi"),
                new Cat(4,    "Isis",   "female")
            };

            Animals[] animals2 =
            {
                new Dog(5,    "Rex",    "male"),
                new Frog(1,   "Fro",    "female"),
                new Cat(3,    "Sisi",   "female"),
                new Dog(3,    "Mimi",   "female"),
                new Frog(2,   "Orf",    "male"),
                new Tomcat(5, "Tomas"),
                new Kitten(2, "Fifi"),
                new Cat(4,    "Isis",   "female")
            };

            Console.WriteLine($"Cats, Years Average: {YearsAverage(animals1, typeof(Cat))}");
            Console.WriteLine($"Dogs, Years Average: {YearsAverage(animals1, typeof(Dog))}");
            Console.WriteLine($"Frogs, Years Average: {YearsAverage(animals1, typeof(Frog))}");
            Console.WriteLine($"Tomcat, Years Average: {YearsAverage(animals1, typeof(Tomcat))}");
            Console.WriteLine($"Kittens, Years Average: {YearsAverage(animals1, typeof(Kitten))}");
        }
Exemple #15
0
        static void Main(string[] args)
        {
            Dog[] dogs = new Dog[]
            {
                new Dog("Sharo", 5, 'F'),
                new Dog("Mimi", 3, 'M'),
                new Dog("Becks", 3.4, 'F')
            };
            Frog[] frogs = new Frog[]
            {
                new Frog("BiBI", 13, 'F'),
                new Frog("Katya", 15, 'M'),
                new Frog("Kolio", 5, 'M'),
                new Frog("Niki", 10, 'M')
            };

            Cat[] cats = new Cat[]
            {
                new Cat("Ass", 3, 'F'),
                new Cat("Hand", 5, 'F'),
                new Cat("Head", 1, 'F'),
                new Cat("Leg", 7, 'M')
            };

            Kitten[] kittens = new Kitten[]
            {
                new Kitten("Malcho", 1),
                new Kitten("Palcho", 2),
                new Kitten("Shalco", 1)
            };

            Tomcat[] tomcats = new Tomcat[]
            {
                new Tomcat("Gosho", 5),
                new Tomcat("Mitko", 4),
                new Tomcat("Pesho", 8)
            };
            Console.WriteLine("Average age of the dogs: {0:F2}", Animal.AverageAge(dogs));
            Console.WriteLine("Average age of the frogs: {0:F2}", Animal.AverageAge(frogs));
            Console.WriteLine("Average age of the cats: {0:F2}", Animal.AverageAge(cats));
            Console.WriteLine("Average age of the kittens: {0:F2}", Animal.AverageAge(kittens));
            Console.WriteLine("Average age of the tomcats: {0:F2}", Animal.AverageAge(tomcats));
        }
        static void Main()
        {
            Kitten penka  = new Kitten("Penka", 1);
            Tomcat gosho  = new Tomcat("Gosho", 5);
            Frog   stamat = new Frog("Stamat", 1, AnimalGender.Male);
            Dog    sharo  = new Dog("Sharo", 15, AnimalGender.Male);
            Cat    pisana = new Cat("Pisana", 3, AnimalGender.Female);

            List <Animal> animals = new List <Animal>()
            {
                penka, gosho, stamat, sharo, pisana
            };

            foreach (var animal in animals)
            {
                Console.WriteLine(animal.ToString());
            }
            Console.WriteLine(Animal.CalculateAverageAge(animals));
        }
        static void Main(string[] args)
        {
            #region Animals lists
            Kitten        malkoKote    = new Kitten(2, "Malko Kote");
            Kitten        poMalkoKote  = new Kitten(1, "Po-malko kote");
            Tomcat        kitHarington = new Tomcat(2, "Kit Harington", true);
            Tomcat        kitkat       = new Tomcat(4, "KitKat", true);
            Frog          boko         = new Frog(5, "Boko", true);
            Frog          kvako        = new Frog(8, "Kvako", true);
            Cat           felicia      = new Cat(4, "Felicia", false);
            Cat           penka        = new Cat(10, "Penka", false);
            Dog           cratos       = new Dog(7, "Cratos", true);
            Dog           sharo        = new Dog(3, "sharo", true);
            List <Kitten> kittens      = new List <Kitten> {
                malkoKote, poMalkoKote
            };
            List <Tomcat> tomcats = new List <Tomcat> {
                kitHarington, kitkat
            };
            List <Frog> frogs = new List <Frog> {
                boko, kvako
            };
            List <Cat> cats = new List <Cat> {
                felicia, penka
            };
            List <Dog> dogs = new List <Dog> {
                cratos, sharo
            };
            #endregion

            #region Tests
            Console.WriteLine(dogs.AverageAge());
            Console.WriteLine(cats.AverageAge());
            Console.WriteLine(frogs.AverageAge());
            Console.WriteLine(kittens.AverageAge());
            Console.WriteLine(tomcats.AverageAge());
            #endregion
        }
        static void Main(string[] args)
        {
            Kitten kit = new Kitten("Kitty", 2);
            Tomcat tom = new Tomcat("Tom", 3);
            Frog leggy = new Frog("Leggy", 6, Gender.Male);
            Dog rex = new Dog("Rex", 4, Gender.Male);
            Cat snow = new Cat("Snow", 5, Gender.Female);

            List<Animal> animals = new List<Animal>() { kit, tom, leggy, rex, snow };
            IntroduceAnimal(animals);

            Kitten[] kittens = new Kitten[] { kit, new Kitten("Lilly", 1), new Kitten("Smurf", 2) };
            Tomcat[] tomcats = new Tomcat[] { tom, new Tomcat("Joefrrey", 3), new Tomcat("Steve", 2), new Tomcat("Paul", 1) };
            Frog[] frogs = new Frog[] { leggy, new Frog("Squirrle", 12, Gender.Female), new Frog("Kurt", 1, Gender.Male) };
            Dog[] dogs = new Dog[] { rex, new Dog("Fluffy", 4, Gender.Female), new Dog("Olde Doge", 12, Gender.Male) };
            Cat[] cats = new Cat[] { snow };

            Console.WriteLine("Kittens: {0:F2}", Animal.AverageAge(kittens));
            Console.WriteLine("Tomcats: {0:F2}", Animal.AverageAge(tomcats));
            Console.WriteLine("Frogs: {0:F2}", Animal.AverageAge(frogs));
            Console.WriteLine("Dogs: {0:F2}", Animal.AverageAge(dogs));
            Console.WriteLine("Cats: {0:F2}", Animal.AverageAge(cats));
        }
Exemple #19
0
        static void Main(string[] args)
        {
            Frog Broasca1 = new Frog(1, "B1", "female");
            Frog Broasca2 = new Frog(2, "B2", "female");
            Frog Broasca3 = new Frog(3, "B3", "male");
            Frog Broasca4 = new Frog(2, "B4", "female");

            Frog[] Broaste = new[] { Broasca1, Broasca2, Broasca3, Broasca4 };

            Dog Caine1 = new Dog(4, "C1", "male");
            Dog Caine2 = new Dog(1, "C2", "male");
            Dog Caine3 = new Dog(10, "C3", "female");
            Dog Caine4 = new Dog(7, "C4", "female");

            Dog[] Caini = new[] { Caine1, Caine2, Caine3, Caine4 };

            Kitten Pisica1 = new Kitten(2, "P1", "female");
            Kitten Pisica2 = new Kitten(6, "P2", "female");
            Kitten Pisica3 = new Kitten(5, "P3", "female");
            Kitten Pisica4 = new Kitten(1, "P4", "female");

            Kitten[] Pisici = new[] { Pisica1, Pisica2, Pisica3, Pisica4 };

            Tomcat Motan1 = new Tomcat(5, "M1", "male");
            Tomcat Motan2 = new Tomcat(5, "M2", "male");
            Tomcat Motan3 = new Tomcat(7, "M3", "male");
            Tomcat Motan4 = new Tomcat(6, "M4", "male");

            Tomcat[] Motani = new[] { Motan1, Motan2, Motan3, Motan4 };

            AverageAgeOfAnimals.PrintBroasteAvaregeAge(Broaste);
            AverageAgeOfAnimals.PrintDogAvaregeAge(Caini);
            AverageAgeOfAnimals.PrintKittenAvaregeAge(Pisici);
            AverageAgeOfAnimals.PrintTomcatAvaregeAge(Motani);

            Console.ReadKey();
        }
        /*3.	Create a hierarchy Dog, Frog, Cat, Kitten, Tomcat and define useful constructors and methods.
         * Dogs, frogs and cats are Animals.
         * All animals can produce sound (specified by the ISound interface).
         * Kittens and tomcats are cats.
         * All animals are described by age, name and sex.
         * Kittens can be only female and tomcats can be only male.
         * Each animal produces a specific sound.
         * Create arrays of different kinds of animals and calculate the average age of each kind of animal using a static method (you may use LINQ).*/
        static void Main()
        {
            //create different animals
            Cat cat = new Cat("Catty", 3, Sex.Female);
            Dog dog = new Dog("Silvestar", 5, Sex.Male);
            Frog froggy = new Frog("Froggy", 1, Sex.Female);
            Kitten kitten = new Kitten("Kitty", 5);
            Kitten kittenCat = new Kitten("Kety", 3);
            Tomcat tomcat = new Tomcat("Tom", 6);

            //produces a specific sound
            Console.Write("Cat make sound: ");
            cat.MakeSound();

            Console.Write("Dog make sound: ");
            dog.MakeSound();

            Console.Write("Frog make sound: ");
            froggy.MakeSound();

            Console.WriteLine();
            //Create arrays of different kinds of animals
            Animal[] animals = { cat, dog, froggy, kitten, tomcat, kittenCat};
            foreach (var ani in animals)
            {
                Console.WriteLine(ani.ToString());
            }

            //calculate the average age of all animals
            double agerageAgeOfAnimals = Animal.CalculateAverageAgeOfAnimals(animals);
            Console.WriteLine();
            Console.WriteLine("Average age of all animals is {0:F3}", agerageAgeOfAnimals);

            //calculate the average age of each kind of animal
            Console.WriteLine("Average of each kind is: ");
            Animal.CalculateAverageAgeOfKind(animals);
        }
Exemple #21
0
        static void Main(string[] args)
        {
            var d1 = new Dog("Beagle", 3, "male");

            d1.Print();
            var d2 = new Dog("Labrador", 6, "female");

            d2.Print();

            var f1 = new Frog("Broscuta", 1, "female");

            f1.Print();

            var c1 = new Cat("Pisica", 2, "female");

            c1.Print();

            var k1 = new Kitten("Kitten", 4);

            ((Cat)k1).Print();
            k1.Gender = "male";
            ((Cat)k1).Print();

            var t1 = new Tomcat("Tomcat", 5);

            t1.Age = 20;
            ((Cat)t1).Print();

            Console.WriteLine("-----------------------------------------");
            Console.WriteLine($"Average age of all animals: {Animal.GetAverageAgeAnimals().ToString("#.##")}");
            Console.WriteLine($"Average age of all dogs: {Dog.GetAverageAgeDogs().ToString("#.##")}");
            Console.WriteLine($"Average age of all frogs: {Frog.GetAverageAgeFrogs().ToString("#.##")}");
            Console.WriteLine($"Average age of all cats: {Cat.GetAverageAgeCats().ToString("#.##")}");

            Console.ReadKey();
        }
Exemple #22
0
        static void Main()
        {
            // Avarage age for dogs

            var listDogs = new List <Animal>()
            {
                new Dog("Rex", 3, "male"),
                new Dog("Riza", 4, "female"),
                new Dog("Sharo", 2, "male"),
                new Dog("Pesho", 8, "male"),
                new Dog("Diksi", 8, "female")
            };

            var avarageAgeDogs = Animal.AvarageAge(Sum(listDogs), listDogs.Count);

            Console.WriteLine(avarageAgeDogs);

            // Avarage age for tomcats and kittens

            var listTomCats = new List <Animal>()
            {
                new Tomcat("Kitty", 2),
                new Tomcat("Pesho", 3),
                new Tomcat("Gosho", 2),
                new Tomcat("Stamat", 6)
            };

            var avarageAgeTomcat = Animal.AvarageAge(Sum(listTomCats), listTomCats.Count);

            Console.WriteLine(avarageAgeTomcat);

            var listKittens = new List <Animal>()
            {
                new Kitten("Pesho", 1),
                new Kitten("Stamat", 4),
                new Kitten("Gosho", 2),
                new Kitten("Penka", 6),
                new Kitten("Radoslav", 8)
            };

            var avarageAgeKittens = Animal.AvarageAge(Sum(listKittens), listKittens.Count);

            Console.WriteLine(avarageAgeKittens);

            // Avarage age fot frog

            var listFrogs = new List <Animal>()
            {
                new Frog("Gosho", 3, "male"),
                new Frog("Pesho", 2, "male"),
                new Frog("Stanka", 1, "female"),
                new Frog("Ivan", 2, "male"),
                new Frog("Cuki", 7, "male")
            };

            var avarageAgeForgs = Animal.AvarageAge(Sum(listFrogs), listFrogs.Count);

            Console.WriteLine(avarageAgeForgs);

            var tomcat = new Tomcat("Pedso", 3);

            tomcat.Sound();
        }
        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());
        }
Exemple #24
0
        static void Main()
        {
            Dog dog = new Dog("Dark", 5, true);

            Console.WriteLine(dog);

            Frog frog = new Frog("Jaburana", 3, false);

            Console.WriteLine(frog);

            Kitten kitten = new Kitten("Pisana", 2);

            Console.WriteLine(kitten);

            Tomcat tomcat = new Tomcat("Tom", 2);

            Console.WriteLine(tomcat);

            Dog[] dogs = new Dog[]
            {
                new Dog("Dark", 2, true),
                new Dog("Mark", 1, true),
                new Dog("Vark", 2, true),
                new Dog("Lara", 3, false)
            };
            Frog[] frogs = new Frog[]
            {
                new Frog("Jaburan4o", 1, true),
                new Frog("Jab4o", 2, true),
                new Frog("Jaja", 4, false),
                new Frog("Jaburana", 4, false),
            };

            Cat[] cats = new Cat[]
            {
                new Cat("Street Excellent", 3, false),
                new Cat("Home Excellent", 5, false),
                new Cat("Persiiko", 1, true),
                new Cat("Garfield", 7, true)
            };

            Kitten[] kittens = new Kitten[]
            {
                new Kitten("Pisana", 3),
                new Kitten("Pis", 10),
                new Kitten("Pisun", 6),
                new Kitten("Pissss", 2),
                new Kitten("MacPis", 4),
            };

            Tomcat[] tomcats = new Tomcat[]
            {
                new Tomcat("Kotio", 5),
                new Tomcat("Gosho", 4),
                new Tomcat("Pesho", 8)
            };

            double dogsAverageAge = dogs.Average(x => x.Age);
            double frogAverageAge = frogs.Average(x => x.Age);
            double catAverageAge  = cats.Average(x => x.Age);

            Console.WriteLine(dogsAverageAge);
            Console.WriteLine(frogAverageAge);
            Console.WriteLine(catAverageAge);



            //или с метод в Animal
            //double dogsAverageAge = Animal.AverageAge(dogs);
        }
Exemple #25
0
 static void Main()
 {
     // Testing all classes and printing the average age of each group of animals
     Console.WriteLine("TESTING ALL CLASSES AND THE AVERAGE AGE METHOD ON THEM:");
     Cat[] cats = new Cat[] { new Cat("Pissy", 3, "Female"),
                              new Cat("Missy", 7, "Female"),
                              new Cat("Tommy", 11, "Male") };
     Console.WriteLine("The average age of the cats is: {0:F2} years.", AverageAge(cats));
     Dog[] dogs = new Dog[] { new Dog("Timmy", 8, "Male"),
                              new Dog("Gabby", 4, "Female"),
                              new Dog("Jake", 13, "Male") };
     Console.WriteLine("The average age of the dogs is: {0:F2} years.", AverageAge(dogs));
     Frog[] frogs = new Frog[] { new Frog("Josh", 1, "Male", "Blue"),
                                 new Frog("Patricia", 7, "Female", "Green"),
                                 new Frog("Helen", 6, "Female", "Black") };
     Console.WriteLine("The average age of the frogs is: {0:F2} years.", AverageAge(frogs));
     Tomcat[] tomcats = new Tomcat[] { new Tomcat("Billy", 5),
                                       new Tomcat("Oliver", 3),
                                       new Tomcat("Sully", 2),
                                       new Tomcat("Lefty", 1) };
     Console.WriteLine("The average age of the tomcats is: {0:F2} years.", AverageAge(tomcats));
     Kitten[] kittens = new Kitten[] { new Kitten("Mandy", 3),
                                       new Kitten("Suzy", 6),
                                       new Kitten("Mary", 2),
                                       new Kitten("Dolly", 5) };
     Console.WriteLine("The average age of the kittens is: {0:F2} years.", AverageAge(kittens));
     Console.WriteLine();
     // Testing the Breed property and the Gender property
     Console.WriteLine("TESTING THE BREED PROPERTY AND THE GENDER PROPERTY:");
     dogs[2].Breed = "Golden retriever";
     Console.WriteLine("{0} is a dog. It's breed is {1} and it's gender is {2}.", dogs[2].Name, dogs[2].Breed, dogs[2].Gender);
     cats[1].Breed = "Persian";
     Console.WriteLine("{0} is a cat. It's breed is {1} and it's gender is {2}.", cats[1].Name, cats[1].Breed, cats[1].Gender);
     tomcats[1].Breed = "Siberian";
     Console.WriteLine("{0} is a tomcat. It's breed is {1} and it's gender is {2}.", tomcats[1].Name, tomcats[1].Breed, tomcats[1].Gender);
     kittens[0].Breed = "Siamese";
     Console.WriteLine("{0} is a kitten. It's breed is {1} and it's gender is {2}.", kittens[0].Name, kittens[0].Breed, kittens[0].Gender);
     Console.WriteLine();
     // Testing the optional methods, that I added
     Console.WriteLine("TESTING THE OPTIONAL METHODS:");
     Console.WriteLine(cats[0].Eat());
     Console.WriteLine(dogs[0].Fetch());
     Console.WriteLine(frogs[0].Hop());
     Console.WriteLine(tomcats[0].Hunt());
     Console.WriteLine(kittens[0].Sleep());
     Console.WriteLine();
     // Testing class Animal and calculating the average age of the different animals in the array
     Animal[] animals = new Animal[5];
     animals[0] = cats[0];
     animals[1] = dogs[1];
     animals[2] = frogs[2];
     animals[3] = tomcats[3];
     animals[4] = kittens[3];
     Console.WriteLine("TESTING THE AVERAGE AGE METHOD ON AN ARRAY OF DIFFERENT ANIMALS:");
     Console.WriteLine("The average age of the animals is: {0:F2} years.", AverageAge(animals));
     Console.WriteLine();
     // Testing the MakeSound method for every animal
     Console.WriteLine("TESTING THE MAKESOUND METHOD ON EVERY CLASS:");
     foreach (var animal in animals)
     {
         Console.WriteLine("The {0} makes that sound \"{1}\"", animal.ToString().Substring(16).ToLower(), animal.MakeSound());
     }
     Console.WriteLine();
 }
Exemple #26
0
        /*
         * 3. Animal hierarchy
         *
         *  Create a hierarchy Dog, Frog, Cat, Kitten, Tomcat and define useful constructors and methods. Dogs, frogs and cats are Animals.
         *  All animals can produce sound (specified by the ISound interface). Kittens and tomcats are cats. All animals are described by age,
         *  name and sex. Kittens can be only female and tomcats can be only male. Each animal produces a specific sound.
         *  Create arrays of different kinds of animals and calculate the average age of each kind of animal using a static method (you may use LINQ).
         *
         */

        static void Main()
        {
            var arrWithCats = new Cat[]
            {
                new Cat(14, "Gosho", Sex.Male),
                new Cat(6, "Mialcho", Sex.Male),
                new Cat(10, "Misha", Sex.Female),
                new Cat(9, "Joystick", Sex.Male),
                new Cat(14, "Macka", Sex.Female)
            };

            Console.ForegroundColor = ConsoleColor.Magenta;
            foreach (var item in arrWithCats)
            {
                Console.WriteLine(item.ProduceSount());
            }
            Console.WriteLine("Average ange of all cats : " + Animal.AverageAge(arrWithCats) + "\n");

            var arrWithKittens = new Kitten[]
            {
                new Kitten(2, "Peshka"),
                new Kitten(1, "Mimka"),
                new Kitten(3, "Dimitrinka"),
                new Kitten(1, "Skilitka")
            };

            Console.ForegroundColor = ConsoleColor.Cyan;
            foreach (var item in arrWithKittens)
            {
                Console.WriteLine(item.ProduceSount());
            }
            Console.WriteLine("Average ange of all kittens : " + Animal.AverageAge(arrWithKittens) + "\n");

            var arrWithTomcats = new Tomcat[]
            {
                new Tomcat(1, "Stamatcho"),
                new Tomcat(2, "Metadoncho"),
                new Tomcat(1, "Ivelincho"),
            };

            Console.ForegroundColor = ConsoleColor.Blue;
            foreach (var item in arrWithTomcats)
            {
                Console.WriteLine(item.ProduceSount());
            }
            Console.WriteLine("Average ange of all tomcats : " + Animal.AverageAge(arrWithTomcats) + "\n");

            var arrWithDogs = new Dog[]
            {
                new Dog(1, "Sharo", Sex.Male),
                new Dog(2, "Pincho", Sex.Male),
                new Dog(3, "Kalina", Sex.Female),
                new Dog(4, "Steven", Sex.Male),
                new Dog(5, "MIla", Sex.Female),
            };

            Console.ForegroundColor = ConsoleColor.Yellow;
            foreach (var item in arrWithDogs)
            {
                Console.WriteLine(item.ProduceSount());
            }
            Console.WriteLine("Average ange of all dogs : " + Animal.AverageAge(arrWithDogs) + "\n");

            var arrWithFrogs = new Frog[]
            {
                new Frog(1, "Japcho", Sex.Male),
                new Frog(2, "Kwa", Sex.Male),
                new Frog(3, "Japka", Sex.Female),
                new Frog(4, "Jaburan", Sex.Male),
                new Frog(5, "Roberta", Sex.Female),
            };

            Console.ForegroundColor = ConsoleColor.Green;
            foreach (var item in arrWithFrogs)
            {
                Console.WriteLine(item.ProduceSount());
            }
            Console.WriteLine("Average ange of all frogs : " + Animal.AverageAge(arrWithFrogs) + "\n");
        }
        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());
        }
        static void Main()
        {
            Kitten maca = new Kitten("Maca", 1);
            Cat tomas = new Cat("Tomas", 5, Gender.male);
            Dog sharo = new Dog("Sharo", 5, Gender.male);
            Frog kroko = new Frog("Kroko", 3, Gender.male);
            Tomcat herkules = new Tomcat("Herkules", 20);

            List<Kitten> kittens = new List<Kitten>()
            {
                maca,
                new Kitten("Pisi", 2),
                new Kitten("Lapa", 1)
            };

            Cat[] cats = new Cat[]
            {
                tomas,
                new Cat("Gosho", 4, Gender.male),
                new Cat("Sara", 8, Gender.female),
                new Cat("Pesho", 11, Gender.male)
            };

            Dog[] dogs = new Dog[]
            {
                sharo,
                new Dog("Chocho", 16, Gender.male),
                new Dog("Lucky", 8, Gender.female),
                new Dog("Sara", 10, Gender.female)
            };

            List<Frog> frogs = new List<Frog>()
            {
                kroko,
                new Frog("Kroki", 2, Gender.female)
            };

            Tomcat[] tomcats = new Tomcat[]
            {
                herkules,
                new Tomcat("Paul", 11),
                new Tomcat("Richard", 9)
            };

            Console.WriteLine("Average ages of animals in collections:");
            Console.WriteLine(string.Format("Tomcats: {0:F2}",Animal.AvgAge(tomcats)));
            Console.WriteLine(string.Format("Kittens: {0:F2}", Animal.AvgAge(kittens)));
            Console.WriteLine(string.Format("Cats: {0:F2}",Animal.AvgAge(cats)));
            Console.WriteLine(string.Format("Dogs: {0:F2}", Animal.AvgAge(dogs)));
            Console.WriteLine(string.Format("Frogs: {0:F2}", Animal.AvgAge(frogs)));

            Console.WriteLine("\nSounds the animals make:");
            Console.Write("Kitten: ");
            maca.MakeSound();
            Console.Write("Tomcat: ");
            herkules.MakeSound();
            Console.Write("Cat: ");
            tomas.MakeSound();
            Console.Write("Dog: ");
            sharo.MakeSound();
            Console.Write("Frog: ");
            kroko.MakeSound();
        }
Exemple #29
0
 public Tomcat(Tomcat tomcat) : base((Cat)tomcat)
 {
 }
        /* Create a hierarchy Dog, Frog, Cat, Kitten, Tomcat and define useful constructors and methods.
           Dogs, frogs and cats are Animals. All animals can produce sound (specified by the ISound interface).
           Kittens and tomcats are cats. All animals are described by age, name and sex.
           Kittens can be only female and tomcats can be only male. Each animal produces a specific sound.
           Create arrays of different kinds of animals and calculate the average age of each
           kind of animal using a static method (you may use LINQ).
         */
        public static void Main()
        {
            Dog[] dogs = new Dog[]
            {
                new Dog("Jaro", 7, true, "Golden Retriever"),
                new Dog("Sharo", 3, true, "German Sheperd"),
                new Dog("Doge", 5, true, "Labrador Retriever"),
                new Dog("Estel", 10, false, "Pincher")
            };

            Frog[] frogs = new Frog[]
            {
                new Frog("Kikirica", 13, false),
                new Frog("Jaba", 15, false),
                new Frog("Froggy", 5, true),
                new Frog("Nikoleta Lozanova", 10, false)
            };

            Cat[] cats = new Cat[]
            {
                new Cat("Street Excellent", 3, false),
                new Cat("Home Excellent", 5, false),
                new Cat("Persiiko", 1, true),
                new Cat("Garfield", 7, true)
            };

            Kitten[] kittens = new Kitten[]
            {
                new Kitten("Malcho", 1),
                new Kitten("Palcho", 2),
                new Kitten("Shalco", 1)
            };

            Tomcat[] tomcats = new Tomcat[]
            {
                new Tomcat("Kotio", 5),
                new Tomcat("Gosho", 4),
                new Tomcat("Pesho", 8)
            };

            double dogsAverageAge = Animal.AverageAge(dogs);
            double frogsAverageAge = Animal.AverageAge(frogs);
            double catsAverageAge = Animal.AverageAge(cats);
            double kittensAverageAge = Animal.AverageAge(kittens);
            double tomcatsAverageAge = Animal.AverageAge(tomcats);
            Console.WriteLine("Average age of the dogs: {0:F2}", dogsAverageAge);
            Console.WriteLine("Average age of the frogs: {0:F2}", frogsAverageAge);
            Console.WriteLine("Average age of the cats: {0:F2}", catsAverageAge);
            Console.WriteLine("Average age of the kittens: {0:F2}", kittensAverageAge);
            Console.WriteLine("Average age of the tomcats: {0:F2}", tomcatsAverageAge);
            Console.WriteLine(new string('-', 10));
            Console.WriteLine("Actions: ");
            Console.WriteLine(tomcats[0].Hunt());
            Console.WriteLine((cats[1].BeGracious()));
            Console.WriteLine(dogs[2].Fetch());
            Console.WriteLine(frogs[1].JumpAround());
            Console.WriteLine(new string('-', 10));
            Console.WriteLine("Sounds: ");
            cats[0].MakeSound();
            dogs[1].MakeSound();
            frogs[2].MakeSound();
        }