Пример #1
0
        static void Main(string[] args)
        {
            var m01 = new Mammal();

            m01.Height = 100;
            m01.Length = 150;
            m01.Weight = 2000;

            var d01 = new Dog();

            d01.Height = 80;
            d01.Length = 50;
            d01.Weight = 1000;
            d01.DogID  = "dog01";
            Console.WriteLine($"Dog has height {d01.Height}, weight {d01.Weight} and length {d01.Length}");
            //var counter = 0;
            for (int i = 1; i <= 20; i++)
            {
                //same height, lenght, width but ID is dog + i
                //create dog
                Dog newDog = new Dog();
                newDog.Height = 80;
                newDog.Length = 50;
                newDog.Weight = 1000;
                newDog.DogID  = $"dog{i}";
                dogs.Add(newDog);
            }

            foreach (var dog in dogs)
            {
                Console.WriteLine($"Dog has height {dog.Height}, weight {dog.Weight} and length {dog.Length} and ID {dog.DogID}");
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            var m01 = new Mammal();

            m01.Weight = 100;
            m01.Length = 150;
            m01.Weight = 2000;
            var d01 = new Dog();

            d01.Weight = 80;
            d01.Length = 50;
            d01.Height = 1000;
            d01.DogID  = "dog01";
            Console.WriteLine($"Dog has height {d01.Height}, weight {d01.Weight} and " +
                              $"length {d01.Length}");
            for (int i = 1; i <= 20; i++)
            {
                // create dog
                Dog newdog = new Dog();
                newdog.DogID  = $"dog{i}";
                newdog.Length = 100;
                newdog.Height = 50;
                newdog.Weight = 30;
                // add dog to list of dogs
                dogs.Add(newdog);
            }
            // print all dogs
            foreach (var dog in dogs)
            {
                Console.WriteLine($"{dog.DogID} has length {dog.Length}");
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            var m01 = new Mammal();

            m01.Height = 100;
            m01.Length = 150;
            m01.Weight = 2000;

            var d01 = new Dog();

            d01.Height = 80;
            d01.Length = 50;
            d01.Weight = 1000;
            d01.DogID  = "Dog01";

            Console.WriteLine($"Dog has height {d01.Height}, weight {d01.Weight} and length {d01.Length}");

            for (int i = 1; i <= 20; i++)
            {
                // Same height, length and width but different ID
                Dog newdog = new Dog();
                newdog.DogID  = $"{i}";
                newdog.Height = 100;
                newdog.Weight = 2000;
                newdog.Length = 150;

                dogs.Add(newdog);
            }

            foreach (var Dog in dogs)
            {
                Console.WriteLine($"Dog number {Dog.DogID}, has height {d01.Height}, weight {d01.Weight} and length {d01.Length}");
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            var m01 = new Mammal();

            m01.Height = 100;
            m01.Length = 150;
            m01.Weight = 2000;
            var d01 = new Dog();

            d01.Height = 80;
            d01.Length = 50;
            d01.Weight = 1000;
            d01.DogID  = "dog01";
            Console.WriteLine($"Dog has height {d01.Height}, weight {d01.Weight} and length {d01.Length}");
            for (int i = 1; i <= 20; i++)
            {
                //same height, length, weight but ID is 'dog' + i
                var newdog = new Dog();
                newdog.Height = 80;
                newdog.Length = 50;
                newdog.Weight = 1000;
                newdog.DogID  = $"dog{i}";
                dogs.Add(newdog);
            }
            foreach (var dog in dogs)
            {
                Console.WriteLine($"{dog.DogID}");
            }
        }