Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 154195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:56:09+00:00 2026-05-11T09:56:09+00:00

Can you give me an almost overly simplistic understanding of abstract class vs inheritance

  • 0

Can you give me an almost overly simplistic understanding of abstract class vs inheritance use and help me so I can truly understand the concept and how to implement? I have a project I’m trying to complete, and am lost on how to implement. I’ve been chatting with my professor and been told off pretty much, saying that if I can’t figure it out, I’m probably not ready for the course. I have OVERCOVERED the prerequestite courses, and still have trouble understanding these concepts.

To clarify, the project as I’ve done so far is below. I don’t have the dog/cat classes etc filled out yet. Can you give me a pointer. I’m not asking for anyone to give me the ‘answers.’ I just am lost on where to go with this. I take online courses and his communication efforts with me have been troubling. I just finished with 4.0 with all my other courses, so I’m willing to put the effort in, but I’m lost in the comprehension of these concepts and how to PRACTICALLY apply them.

Any comments or help that will let me progress further in this project?

The description of what I’m to implement is as follows:

Overview:

The purpose of this exercise is to demonstrate the use of Interfaces, Inheritance, Abstract classes, and Polymorphism. Your task is to take the supplied program shell and ADD the appropriate classes and corresponding class members/methods to get this program to function correctly. You may not make changes to any of the code supplied, you may only add the classes you write. Although there are numerous ways to get the program working, you must use techniques that demonstrate the use of Interfaces,
Inheritance, Abstract classes, and Polymorphism. Again, to make clear, you can add to the supplied code but you cannot change or delete any of it. The code that is supplied will work with very little additional code and will satisfy the requirements of the exercise.

If you successfully complete the assignment, your program should output the following statements when run:

My name is Spot, I am a Dog

My name is Felix, I am a Cat

Requirements:

1) You must have an abstract base class called ‘Animal’ from which the Dog and Cat classes derive.

2) The Animal base class must derive from the Interface ‘IAnimal’, it is the only class that should derive from IAnimal.

3) Since all animals have a name and a name is not an attribute that is specific to a dog or a cat, the Animal

base class should be where the name is stored and where the WhatIsMyName get-property is implemented.

4) You will need to create a Dog and a Cat class that will derive only from the Animal base class.

5) The Dog and Cat classes should implement the WhatAmI get-property and return the appropriate string value.

Code you can’t change:

using System;  namespace IT274_U2 {     public interface IAnimal     {         string WhatAmI { get; }         string WhatIsMyName { get; }     }      public class TesterClass     {         public static void DescribeAnimal(IAnimal animal)         {             Console.WriteLine('My name is {0}, I am a {1}', animal.WhatIsMyName, animal.WhatAmI);         }          static void Main(string[] args)         {             Dog mydog = new Dog('Spot');             Cat mycat = new Cat('Felix');             DescribeAnimal(mydog);             DescribeAnimal(mycat);         }     } } 

///////////////////////

Code I’ve written so far:

using System;   namespace IT274_U2 {     public interface IAnimal     {         string WhatAmI { get; }         string WhatIsMyName { get; }     }       public class Dog     {         public abstract string WhatAmI         {             get;             set;         }     }//end public class Dog      public class Cat     {     public abstract string WhatIsMyName       {         get;         set;     }     }//end public class Cat      public abstract class Animal : IAnimal     {     // fields     protected string Dog;     protected string Cat;                    // implement WhatIsMyName       //properties     public abstract String Dog     {         get;           set;     }     public abstract String Cat     {         get;         set;     }     public abstract string WhatIsMyName();      } //end public abstract class Animal       public class TesterClass     {         public static void DescribeAnimal(IAnimal animal)         {             Console.WriteLine('My name is {0}, I am a {1}', animal.WhatIsMyName, animal.WhatAmI);         }          static void Main(string[] args)         {              Dog mydog = new Dog('Spot');             Cat mycat = new Cat('Felix');             DescribeAnimal(mydog);             DescribeAnimal(mycat);         }     } } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T09:56:10+00:00Added an answer on May 11, 2026 at 9:56 am

    EDIT:

    I have taken the body of code for each class out – If you want to see my answer, have a look at the edit revisions 🙂

    First off we define the interface

    public interface IAnimal {     string WhatAmI { get; }     string WhatIsMyName { get; } } 

    Any class that implements this interface must implement these properties. An interface is like a contract; a class implementing an interface agrees to provide an implementation of the interface’s methods, properties events or indexers.

    Next, we need to define your abstract Animal class

    public abstract class Animal : IAnimal {     //Removed for Training, See Edit for the code } 

    The fact that the class is abstract indicates that the class is intended only to be a base class for other classes. We have implemented both properties of the interface and also have a private field to store the animal name. In addition, we have made the WhatAmI property accessor abstract so that we can implement our own specific property accessor logic in each derived class and have also defined a constructor that accepts a string argument and assigns the value to the _name private field.

    Now, let’s define our Cat and Dog classes

    public class Dog : Animal {     //Removed for Training, See Edit for the code }  public class Cat : Animal {     //Removed for Training, See Edit for the code } 

    Both classes inherit from Animal and each has a constructor that defines a string argument and passes that argument as a parameter to the base constructor. In addition, each class implements it’s own property accessor for WhatAmI, returning a string of their type, respectively.

    For the rest of the code

    public class Program {     public static void DescribeAnimal(IAnimal animal)     {         Console.WriteLine('My name is {0}, I am a {1}', animal.WhatIsMyName, animal.WhatAmI);     }      static void Main(string[] args)     {         Dog mydog = new Dog('Spot');         Cat mycat = new Cat('Felix');         DescribeAnimal(mydog);         DescribeAnimal(mycat);         Console.ReadKey();     } } 

    the static method DescribeAnimal accepts an IAnimal as an argument and writes out the values returned by the WhatIsMyName and WhatAmI property accessors for the passed in IAnimal.

    Since Animal implements IAnimal and both Dog and Cat inherit from Animal, any Cat or Dog object can be passed as a parameter to the DescribeAnimal method.

    I hope that I have explained this clearly, If anyone feels my choice of words needs tightening up, please comment and I will be happy to edit my answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Great ruby on rails examples of almost real world applications: Can somebody give some
Question: How can I give a new user almost all privileges, but still keep
Someone can give me short explanation how to create bitmap runtime using GDI/GDI+ and
who can give me a simple code , i want a simplest way to
Who can give me a link for the operator= of vector in MSDN? Why
I hope you can give me a hand on this. It's been bothering me
Facebook API can give the pages a user admins. Suppose that it returns me
I'm hoping you can give me some pointers... For some reason when I try
In how many ways we can give color info in X/HTML, css? I know
Does anyone know of any resources that can give me an idea of how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.