Esempio n. 1
0
        static void Main(string[] args)
        {
            // TODO Be sure to follow best practice when creating your classes

            // DONE Create a class Animal
            // DONE give this class 4 members that all Animals have in common


            // DONE Create a class Bird
            // DONE give this class 4 members that are specific to Bird
            // DONE Set this class to inherit from your Animal Class

            // DONE Create a class Reptile
            // DONE give this class 4 members that are specific to Reptile
            // DONE Set this class to inherit from your Animal Class



            /*DONE Create an object of your Bird class
             * DONE give values to your members using the object of your Bird class
             *
             * Creatively display the class member values
             */


            var newBird = new Birds();

            {
                newBird.FeatherColor = "Blue";
                newBird.WingLength   = 22.45;
                newBird.CanFly       = false;
                newBird.ChirpNoise   = "tweet tweet";
            };


            /*Create an object of your Reptile class
             *  give values to your members using the object of your Bird class
             *
             * Creatively display the class member values
             */

            var newReptile = new Reptiles();

            {
                newReptile.HasScales   = true;
                newReptile.LegCount    = 0;
                newReptile.IsPoisonous = true;
                newReptile.TailLength  = 26.74;
            };


            var myAnimals = new Animals[] { newBird, newReptile };

            foreach (var animal in myAnimals)
            {
                Console.WriteLine($"Land, Air, or Sea?: {animal.LandAirSea}");
                Console.WriteLine($"Age: {animal.Age}");
                Console.WriteLine($"Is Dangerous?: {animal.IsDangerous}");
                Console.WriteLine($"Weight?: {animal.Weight}");
                Console.WriteLine("");
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            // TODO Be sure to follow best practice when creating your classes

            // Create a class Animal
            // give this class 4 members that all Animals have in common


            // Create a class Bird
            // give this class 4 members that are specific to Bird
            // Set this class to inherit from your Animal Class

            // Create a class Reptile
            // give this class 4 members that are specific to Reptile
            // Set this class to inherit from your Animal Class



            /*Create an object of your Bird class
             *  give values to your members using the object of your Bird class
             *
             * Creatively display the class member values
             */
            var b1 = new Birds()
            {
                Species = "parot",
                Color   = "red",
                Sex     = "male",
                Legs    = 2,
                CanFly  = "yes",
                Wings   = 2,
                Beak    = "does have",
                LayEggs = "it does",
            };

            var lizard = new Reptiles()
            {
                Species     = "ingunana",
                Color       = "green",
                Sex         = "female",
                Legs        = 4,
                ChangeColor = "can not",
                Malt        = "it does",
                ColdBlood   = "it is",
                Posionus    = "is not"
            };


            var myAnimals = new Animals[] { b1, lizard };

            foreach (var animal in myAnimals)
            {
                Console.WriteLine($"The Animal is a {animal.Species}");
                Console.WriteLine($"The Animal is the color {animal.Color}");
                Console.WriteLine($"The Animal is a {animal.Sex}");
                Console.WriteLine($"The Animal has {animal.Legs} legs");
                Console.WriteLine("");
            }



            /*Create an object of your Reptile class
             *  give values to your members using the object of your Bird class
             *
             * Creatively display the class member values
             */
        }