Question

Write in C# Create an inheritance hierarchy that is: at least three levels deep (one parent...

Write in C#

Create an inheritance hierarchy that is:

  • at least three levels deep (one parent class, two child classes, one child class of one the child classes)
  • shares at least one property through all levels
  • has at least one property or method that is modified inside of each child class
0 0
Add a comment Improve this question Transcribed image text
Answer #1

class Parent

{

public string name;

public Parent(string name)

{

this.name = name

}

public void printName()

{

Console.WriteLine("Parent : ", + name);

}

}

class Child1 : Parent

{

public Child1(string name) : base(name)

{}

public void printName()

{

Console.WriteLine("Child1 : ", + name);

}

}

class Child2 : Parent

{

public Child2(string name) : base(name)

{}

public void printName()

{

Console.WriteLine("Child2 : ", + name);

}

}

class Child12 : Child1

{

  public Child12(string name) : base(name)

{}

public void printName()

{

Console.WriteLine("Child12 : ", + name);

}

}

Add a comment
Know the answer?
Add Answer to:
Write in C# Create an inheritance hierarchy that is: at least three levels deep (one parent...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • UML Class Diagram with Inheritance Objectives Use UML Correctly indicate inheritance Demonstrate permissions Understand inheritance relationships...

    UML Class Diagram with Inheritance Objectives Use UML Correctly indicate inheritance Demonstrate permissions Understand inheritance relationships Labwork Please read all of the directions carefully. You will create a UML class diagram reflecting the class hierarchy for a fictional program that manages university personnel as constructed according to the graph displayed below. You will need to think about the attributes and behaviors that are unique to each class, and also those attributes and behaviors that are common amongst the subclasses and...

  • create a program that uses multiple inheritance by creating two base classes in C++ - an...

    create a program that uses multiple inheritance by creating two base classes in C++ - an Alien class and a Soldier class. -create three child classes from the Alien class and three child classes from the Soldier class. -use multiple inheritance to create five unique classes that each have a child Alien class and a child Soldier class as parents. -have the program print out each of the five class's characteristics when objects are created from the grandchildren classes.

  • JAVA: Quadrilateral Inheritance Hierarchy Write an inheritance hierarchy for classes Quadrilateral, Parallelogram, Rectangle, and Square. Use...

    JAVA: Quadrilateral Inheritance Hierarchy Write an inheritance hierarchy for classes Quadrilateral, Parallelogram, Rectangle, and Square. Use Quadrilateral as the superclass of the hierarchy. Create and use a Point class to represent the points in each shape. Make the hierarchy as deep as possible, i.e. more than two levels. Specify the instance variables and methods for each class. The private instance variables of Quadrilateral should be the x-y coordinate pairs for the four endpoints of the Quadrilateral. A program that instantiates...

  • Use inheritance to create a hierarchy of Exception classes -- EndOfSentenceException, PunctuationException, and CommaException. EndOfSentenceException is...

    Use inheritance to create a hierarchy of Exception classes -- EndOfSentenceException, PunctuationException, and CommaException. EndOfSentenceException is the parent class to PunctuationException, which is the parent class to CommaException. Test your classes in a Driver class with a main method that asks the user to input a sentence. If the sentence ends in anything except a period (.), exclamation point (!), or question mark (?), the program should throw a PunctuationException. If the sentence specifically ends in a comma, the program...

  • Java code for the following inheritance hierarchy figure.. 1. Create class Point, with two private instance...

    Java code for the following inheritance hierarchy figure.. 1. Create class Point, with two private instance variables x and y that represented for the coordinates for a point. Provide constructor for initialising two instance variables. Provide set and get methods for each instance variable, Provide toString method to return formatted string for a point coordinates. 2. Create class Circle, its inheritance from Point. Provide a integer private radius instance variable. Provide constructor to initialise the center coordinates and radius for...

  • C++ ONLY PLEASE Problem Description: Objective: Create Inheritance Hierarchy to Demonstrate Polymorphic Behavior Create a Rectangle...

    C++ ONLY PLEASE Problem Description: Objective: Create Inheritance Hierarchy to Demonstrate Polymorphic Behavior Create a Rectangle Class Derive a Square Class from the Rectangle Class Derive a Right Triangle Class from the Rectangle Class Create a Circle Class Create a Sphere Class Create a Prism Class Define any other classes necessary to implement a solution Define a Program Driver Class for Demonstration a) Create a Container to hold objects of the types described above b) Create and Add two(2) objects...

  • Can you please pick Automobile For this assignment. Java Programming Second Inheritance OOP assignment Outcome: Student...

    Can you please pick Automobile For this assignment. Java Programming Second Inheritance OOP assignment Outcome: Student will demonstrate the ability to use inheritance in Java programs. Program Specifications: Programming assignment: Classes and Inheritance You are to pick your own theme for a new Parent class. You can pick from one of the following: Person Automobile Animal Based on your choice: If you choose Person, you will create a subclass of Person called Student. If you choose Automobile, you will create...

  • This assignment helps you understand Inheritance. We want to create a superclass or parent class called...

    This assignment helps you understand Inheritance. We want to create a superclass or parent class called Shape. This shape class will have just one method to setBorderColor. Now we need 3 subclasses that extend the Shape class, Circle, Square and Rectangle. In these classes we will need to compute the area of each of the shapes and print it to the console using System.out.println You will need to take in an additional parameter in each of these subclasses -- side...

  • Create the following hierarchy using C#. Create interface IPayable which has a method – GetPaymentAmount(). Create...

    Create the following hierarchy using C#. Create interface IPayable which has a method – GetPaymentAmount(). Create a class Invoice which inherits from IPayable and has following instance data: quantity and price per item. Create class Employee ( has first name, last name and Social Security Number ) and Salaried Employee ( Weekly Salary ) as shown in the hierarchy. Test all classes by creating objects and making use of Interface Polymorphism. «interface IPayable - - - - - . -...

  • Create classes to implement the following inheritance hierarchy: Book TextBook E-Book All books have a title,...

    Create classes to implement the following inheritance hierarchy: Book TextBook E-Book All books have a title, an ISBN number, a cost and a size (i.e., number of pages). Textbooks also have an area designation (such as ComputerScience or Anthropology) and a student discount percentage. E-books contain a platform designation (such as Kindle or Nook). You need only list the elds and a constructor for each class.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT