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, "Kyle"); duck1.SayName(); Frog frog1 = new InheritanceIntro.Frog(3, "Timmy"); frog1.SayName(); Lion lion1 = new InheritanceIntro.Lion(26, "bob"); lion1.SayName(); }
private void SayName_Button_Click(object sender, RoutedEventArgs e) { List <Animal> animals = new List <Animal>(); // 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 animals.Add(dog1); animals.Add(dog2); // Loop through the list and call a method on the objects foreach (Dog d in dogs) { d.SayName(); } Duck duck1 = new Duck(25, "Harry"); Duck duck2 = new Duck(45, "Henrietta"); List <Duck> ducks = new List <Duck>(); animals.Add(duck1); animals.Add(duck2); foreach (Animal an in animals) { an.SayName(); } List <Frog> frogs = new List <Frog>(); Frog frog1 = new Frog(36, "Troy", true); Frog frog2 = new InheritanceIntro.Frog(48, "Caden", false); frogs.Add(frog1); frogs.Add(frog2); foreach (Frog f in frogs) { f.SayName(); } }
private void RibbitButton_Click(object sender, RoutedEventArgs e) { Frog frog = new InheritanceIntro.Frog(); frog.Ribbit(); }
private void Ribbit_Button_Click(object sender, RoutedEventArgs e) { Frog frog1 = new InheritanceIntro.Frog(3, "timmy"); frog1.Ribbit(); }