Ejemplo n.º 1
0
        public static void Main()
        {
            Dog doggy = new Dog(4, "doggy", "male");
            doggy.Says();
            Console.WriteLine();

            Kitten kitt = new Kitten(3, "kitten");
            kitt.Says();
            Console.WriteLine();

            Frog froggy = new Frog(20, "froggy", "female");
            froggy.Says();
            Console.WriteLine();

            Console.WriteLine();
            Animals[] aLotOfAnimals =
                {
                    new Kitten(5, "Pesho 1"),
                    new Frog(12, "Pesho 2", "female"),
                    new Frog(3, "Pesho 3", "male"),
                    new Dog(66, "Pesho 4", "female"),
                    new Kitten(9, "Pesho 5"),
                    new Frog(1, "Pesho 6", "female"),
                    new Frog(0, "Pesho 7", "male"),
                    new Dog(30, "Pesho 8", "male"),
                    new Kitten(11, "Pesho 9"),
                    new Frog(6, "Pesho 10", "female"),
                    new Frog(8, "Pesho 11", "male"),
                    new Dog(8, "Pesho 12", "female"),
                    new Kitten(10, "Pesho 13"),
                };

            Animals.AvgAge(aLotOfAnimals);
        }
Ejemplo n.º 2
0
        static void Main()
        {
            Dog Manny = new Dog();
            Manny.age = 2.5;
            Manny.breed = "Chow Chow";
            Manny.color = "Red";
            Manny.name = "Manny";
            Manny.owner = "Me";
            Manny.personalId = "dog123";
            Manny.sex = "Male";

            Console.WriteLine("Your Dog is called {0} it's {1} years old, the breed is: {2}. The color of the dog is: {3} and the owner is: {4}. The dog is: {5} with personal id {6}.", Manny.name, Manny.age, Manny.breed, Manny.color, Manny.owner, Manny.sex, Manny.personalId);
            Manny.WagTail();
            Console.WriteLine( Manny.SayBau() );
            Console.WriteLine( Manny.MakeNoise() );
            Manny.GoForAWalk();
            Manny.BeHungry();

            List<Dog> dogs = new List<Dog>
            {
                new Dog("Dog", 1.2),
                new Dog("Dogg", 2.4),
                new Dog("Dogy", 3.2),
                new Dog("Doggy", 1.4),
                new Dog("Dogo", 5.2),
                new Dog("Doggo", 6.4),
                new Dog("Dooog", 2.2),
                new Dog("Doooogg", 3.4),
                new Dog("Doga", 3.5),
                new Dog("Dogga", 7.4)
            };

            Console.WriteLine("Average age of dogs is: {0}", dogs.Average(dog => dog.age));

            List<Frog> frogs = new List<Frog>
            {
                new Frog("Gogo", 0.2),
                new Frog("Gogi", 0.3),
                new Frog("Go", 0.1),
                new Frog("Gog", 0.5),
                new Frog("Gogooo", 0.4),
                new Frog("Googo", 0.6),
                new Frog("G", 0.8),
                new Frog("Gmogo", 0.7),
                new Frog("Gmo", 0.9),
                new Frog("Gmog", 1.2),
            };

            Console.WriteLine("Average age of frogs is: {0}", frogs.Average(frog => frog.age));
        }