Question
C sharp please 1. Create the abstract class Animal. This class has one field - name and two methods: getName() and makeNoise(). The makeNoise() method
C sharp please
1. Create the abstract class Animal. This class has one field - name and two methods: getName() and makeNoise(). The makeNoise() method should be abstract. Derive two classes from Animal - Dog and Cat and implement the getName() and the makeNoise() method for each class. Create a container to store animals and then demonstrate how the makeNoise() method works for each type of animal.
2. Declare the abstract Person class that describes a human and the Student class that derives from Person. The attributes in each instance of type Person should include: name, age and id. The attributes in each instance of type Student should include, in addition to those that inherited from class Person, the attribute average. Create a third class Employee that inherits from Person but includes a field for department and company name. In the Person class, write an abstract method, ToString(), that returns the fields of an object. Write getters and setters for the attributes of all three classes. Then create a container to store Person objects and use the ToString() method to demonstrate how polymorphism works
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started