Answered step by step
Verified Expert Solution
Link Copied!

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

  1. Create an abstract class Animal that has:
  1. A protected instance variable Name(string)
  2. Default constructor.
  3. An abstract method Move returns which animal is moving.
  4. A public method Sleep returns a string sleep.
  5. An abstract method Voice returns which the animal sound.
  6. 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.

  1. 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....

  1. 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....

  1. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Build It For The Real World A Database Workbook

Authors: Wilson, Susan, Hoferek, Mary J.

1st Edition

0073197599, 9780073197593

More Books

Students also viewed these Databases questions