コード例 #1
0
ファイル: AnimalsDemo.cs プロジェクト: petyob/TelerikAcademy
    static void Main()
    {
        IVocal[] noisyCreatures = new IVocal[]
        {
            new Dog("Rex", 5, true),
            new Frog("Kermit", 58, true),
            new Dog("Stella", 2, false),
            new Tomcat("Hoho", 8),
            new Pussycat("Cleopatra", 5),
            new Dog("Caesar", 3, true),
        };

        foreach (IVocal noisyCreature in noisyCreatures)
        {
            Console.WriteLine(noisyCreature.GetTypicalSound());
        }

        Animal[] animals = new Animal[]
        {
            new Dog("Rex", 5, true),
            new Frog("Kermit", 58, true),
            new Dog("Stella", 2, false),
            new Tomcat("Hoho", 8),
            new Tomcat("George", 3),
            new Tomcat("Garfield", 10),
            new Pussycat("Cleopatra", 5),
            new Dog("Betty", 12, false),
            new Dog("Mike", 7, true),
            new Dog("Caesar", 3, true),
        };

        decimal averageAge = Animal.GetAverageAge(animals);

        Console.WriteLine("Average age: {0:F2}", averageAge);

        var averageAges = GetAverageAges(animals);

        foreach (var tuple in averageAges)
        {
            Console.WriteLine("Animal: {0}, Average Age: {1:F2}", tuple.Item1, tuple.Item2);
        }
    }
コード例 #2
0
ファイル: AnimalsDemo.cs プロジェクト: nikolaynikolov/Telerik
    static void Main()
    {
        IVocal[] noisyCreatures = new IVocal[]
        {
            new Dog("Rex", 5, true),
            new Frog("Kermit", 58, true),
            new Dog("Stella", 2, false),
            new Tomcat("Hoho", 8),
            new Pussycat("Cleopatra", 5),
            new Dog("Caesar", 3, true),
        };

        foreach (IVocal noisyCreature in noisyCreatures)
        {
            Console.WriteLine(noisyCreature.GetTypicalSound());
        }

        Animal[] animals = new Animal[]
        {
            new Dog("Rex", 5, true),
            new Frog("Kermit", 58, true),
            new Dog("Stella", 2, false),
            new Tomcat("Hoho", 8),
            new Tomcat("George", 3),
            new Tomcat("Garfield", 10),
            new Pussycat("Cleopatra", 5),
            new Dog("Betty", 12, false),
            new Dog("Mike", 7, true),
            new Dog("Caesar", 3, true),
        };

        decimal averageAge = Animal.GetAverageAge(animals);
        Console.WriteLine("Average age: {0:F2}", averageAge);

        var averageAges = GetAverageAges(animals);
        foreach (var tuple in averageAges)
        {
            Console.WriteLine("Animal: {0}, Average Age: {1:F2}", tuple.Item1, tuple.Item2);
        }
    }