Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create an abstract class Animal that has: A protected instance variable Name(string) Default constructor. An abstract method Move returns which animal is moving. A public
- Create an abstract class Animal that has:
- A protected instance variable Name(string)
- Default constructor.
- An abstract method Move returns which animal is moving.
- A public method Sleep returns a string sleep.
- An abstract method Voice returns which the animal sound.
- Create a static Get_Random_Animal, which return a random generated animal using random class:
If random number <5: create a Cat object.
If random number >=5: create a Mouse object.
- Create a class Cat that inherits for Animal and has extra private instance variable Age (int) and Height (int). Also, provide a constructor that initializes the three instance variables. Then, override the method voice that returns Meo and method move to cat move....
- Create a class Mouse that inherits form Animal with additional data member weight (int). Provide two constructors (default and override that initializes name and weight). Use the set and get properties to access the weight data member. Then, override the method Voice to squeak and move to mouse move....
- Test your classes using Console Application:
Create 5 random Objects (polymorphically), and for each object print move and voice methods.
If the object is cat: print its name, height and age.
If the object is mouse: print its name and weight.
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