Question: In C#... Create two classes to demonstrate how inheritance works. Create a base class for Dog that can be used to generically defines properties and

In C#...

Create two classes to demonstrate how inheritance works. Create a base class for Dog that can be used to generically defines properties and methods used for all dogs. Add as many members to the class as youd like, but at a minimum, add a method for Bark() when calling this method, write a response to the console ex: Fido says WUFF.

Next, create a Poodle class that derives from the Dog class. Add a new Groom() method. When calling this method, write something to the console such as All poodles must be groomed.

Now, from your main form, create an object of the Dog class and a separate object of the Poodle class. For both objects, call the Bark() method. You should see that even though we didnt define Bark() in the Poodle class directly, we have access to the method since Poodle inherits from Dog. Also, call the Groom() method on the Poodle class.

Note - You should also see that if you try to call Groom() from the Dog object you created, you arent able to since the method isnt defined for Dog, but only Poodle

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!