Question: You are tasked with developing a robust system for managing different types of animals in a zoo. The system must adhere to object - oriented
You are tasked with developing a robust system for managing different types of animals in a zoo. The system must adhere to objectoriented principles, utilizing interfaces, abstract classes, and inheritance effectively.
Define an interface named IAnimal with the following members:
Method void Eat to simulate the animal's eating behaviour.
Property string Name to store the name of the animal.
Property int Age to store the age of the animal.
Create an abstract class named AnimalBase that implements the IAnimal interface. The AnimalBase class should include the following:
An abstract method void MakeSound to be implemented by derived classes.
Implementation of the IAnimal interface members.
Additional property string Species to store the species of the animal.
Derive two concrete classes from the AnimalBase class:
Lion: Represents a lion in the zoo.
Implement the MakeSound method to output the lion's roar.
Set the Species property to "Panthera leo".
Elephant: Represents an elephant in the zoo.
Implement the MakeSound method to output the elephant's trumpet.
Set the Species property to "Loxodonta africana".
Write a console application to test the functionality of your implemented classes. The application should create instances of both Lion and Elephant classes, call their methods to simulate eating and making sounds, and display relevant information about each animal.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
