Ejemplo n.º 1
0
        private void SayName_Button_Click(object sender, RoutedEventArgs e)
        {
            // Define a new List of dogs
            List <Dog> dogs = new List <Dog>();

            // Instantiate some dog objects
            Dog dog1 = new Dog("Muppet", 20, "Rolf");
            Dog dog2 = new Dog("Golden Retriever", 30, "Air Bud");

            // Add the dogs to the list
            dogs.Add(dog1);
            dogs.Add(dog2);

            // Loop through the list and call a method on the objects
            foreach (Dog d in dogs)
            {
                d.sayname();
            }
            duck duck1 = new InheritanceIntro.duck(9, "scrudge mcduck");

            duck1.sayname();
            frog frog1 = new InheritanceIntro.frog(3, "frogget");

            frog1.sayname();
            worm worm1 = new InheritanceIntro.worm(1, "greg");

            worm1.sayname();
        }
Ejemplo n.º 2
0
        private void SayName_Button_Click(object sender, RoutedEventArgs e)
        {
            // Define a new List of dogs
            List <Dog> dogs = new List <Dog>();

            // Instantiate some dog objects
            Dog dog1 = new Dog("Muppet", 20, "Rolf");
            Dog dog2 = new Dog("Golden Retriever", 30, "Air Bud");

            // Add the dogs to the list
            dogs.Add(dog1);
            dogs.Add(dog2);

            // Loop through the list and call a method on the objects
            foreach (Dog d in dogs)
            {
                d.SayName();
            }

            duck duck1 = new InheritanceIntro.duck(9, "Joseph Stalin");

            duck1.SayName();
        }