Question

C# Now that we've learned about interfaces and inheritance, let's think of a system where we...

C#

Now that we've learned about interfaces and inheritance, let's think of a system where we can apply interfaces and inheritance to break down the system into multiple components and any opportunities that allow for sharing code using inheritance.

1. Describe a system that can be broken down into multiple components

2. What are some of the components that make up this system that would be good interfaces?

3. For any classes that you create for your interfaces, is there a good opportunity to use inheritance to share logic for different derived classes?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Having said that Inheritance is one of the main feature in OOPS programming.

lets get a deep dive into it:

let me take automobiles like cars , trucks , bikes etc.

only common among all above is they all are vehicles, which has common attributes like brand name, manufacture year, color,etc and actions like horn, move, etc.

!: vehicle can be a interface

2.as mentioned above common action like horn, start, move ,stop are actions and attributes like names and features etc

let us see how inheritance will work, example program:

using System;

public class ParentClass
{
public ParentClass()
{
Console.WriteLine("Parent Constructor.");
}

public void print()
{
//action
Console.WriteLine("I'm a Parent Class.");
}
}

public class ChildClass : ParentClass
{
public ChildClass()
{
Console.WriteLine("Child Constructor.");
}

public static void Main()
{
ChildClass child = new ChildClass();
//above constructor will first instantiate parent class constructor and the derived class constructor

child.print();
}
}

/*output:

Parent Constructor.
Child Constructor.
I'm a Parent Class.*/

3.

example:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Inherit
{
class inheri : vehicle
{
public void Noise()
{
Console.WriteLine("noiseeeeee like horn !! ");
}
static void Main(string[] args)
{
inheri obj = new inheri();
obj.mode();
obj.model();
obj.Noise();
Console.Read();
}
}
class Type
{
public void mode()
{
Console.WriteLine("There are Many Modes of Transport !!");
}
}
class vehicle : Type
{
public void model()
{
Console.WriteLine("brand new model !!");
}
}
}

Eusing System; cusers\lsirigirix076817 source\repos\ConsoleAp using System.collections.Generic; using System. Linq; using Sys

Add a comment
Know the answer?
Add Answer to:
C# Now that we've learned about interfaces and inheritance, let's think of a system where we...
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
  • In Java plz due today Assignment 4 - Email, Shwitter and Inheritance Select one option from...

    In Java plz due today Assignment 4 - Email, Shwitter and Inheritance Select one option from below. All (both) options are worth the same number of points. The more advanced option(s) are provided for students who find the basic one too easy and want more of a challenge. OPTION A (Basic): Message, EMail and Tweet Understand the Classes and Problem Every message contains some content ("The British are coming! The British are coming!"). We could enhance this by adding other...

  • C# - Inheritance exercise I could not firgure out why my code was not working. I...

    C# - Inheritance exercise I could not firgure out why my code was not working. I was hoping someone could do it so i can see where i went wrong. STEP 1: Start a new C# Console Application project and rename its main class Program to ZooPark. Along with the ZooPark class, you need to create an Animal class. The ZooPark class is where you will create the animal objects and print out the details to the console. Add the...

  • C++ please Let's pretend that we can still go out to eat at a restaurant. Suppose...

    C++ please Let's pretend that we can still go out to eat at a restaurant. Suppose we have the job to make a program that accepts a dinner reservation. The information collected will be the name of the customer, the date for the reservation, the time for the reservation (good choice for a hierarchical struct), the number in the party, email address (for updates) and phone number. Define a hierarchical structure for a dinner reservation that will contain the above...

  • Option 1: Authentication System For security-minded professionals, it is important that only the appropriate people gain...

    Option 1: Authentication System For security-minded professionals, it is important that only the appropriate people gain access to data in a computer system. This is called authentication. Once users gain entry, it is also important that they only see data related to their role in a computer system. This is called authorization. For the zoo, you will develop an authentication system that manages both authentication and authorization. You have been given a credentials file that contains credential information for authorized...

  • Summary Write a program that demonstrates the skills you’ve learned throughout this quarter. This type of...

    Summary Write a program that demonstrates the skills you’ve learned throughout this quarter. This type of project offers only a few guidelines and requirements, allowing you to invest as much time, effort and imagination as you want.  Submit your java programs (*.java) and any other I/O (*.txt) via Canvas  You’ve worked quite hard to make it this far, so have a bit of fun with this project! Design Brief: Use Case Scenario You are hired to develop a...

  • IN JAVA PLS DUE TODAY Assignment 4 - Email, Shwitter and Inheritance Select one option from...

    IN JAVA PLS DUE TODAY Assignment 4 - Email, Shwitter and Inheritance Select one option from below. All (both) options are worth the same number of points. The more advanced option(s) are provided for students who find the basic one too easy and want more of a challenge. OPTION A (Basic): Message, EMail and Tweet Understand the Classes and Problem Every message contains some content ("The British are coming! The British are coming!"). We could enhance this by adding other...

  • Programming Project 3 See Dropbox for due date Project Outcomes: Develop a Java program that uses:...

    Programming Project 3 See Dropbox for due date Project Outcomes: Develop a Java program that uses: Exception handling File Processing(text) Regular Expressions Prep Readings: Absolute Java, chapters 1 - 9 and Regular Expression in Java Project Overview: Create a Java program that allows a user to pick a cell phone and cell phone package and shows the cost. Inthis program the design is left up to the programmer however good object oriented design is required.    Project Requirements Develop a text...

  • C LANGUAGE. PLEASE INCLUDE COMMENTS :) >>>>TheCafe V2.c<<<< #include ...

    C LANGUAGE. PLEASE INCLUDE COMMENTS :) >>>>TheCafe V2.c<<<< #include <stdio.h> int main() { int fries; // A flag denoting whether they want fries or not. char bacon; // A character for storing their bacon preference. double cost = 0.0; // The total cost of their meal, initialized to start at 0.0 int choice; // A variable new to version 2, choice is an int that will store the // user's menu choice. It will also serve as our loop control...

  • Java Painter Class This is the class that will contain main. Main will create a new...

    Java Painter Class This is the class that will contain main. Main will create a new Painter object - and this is the only thing it will do. Most of the work is done in Painter’s constructor. The Painter class should extend JFrame in its constructor.  Recall that you will want to set its size and the default close operation. You will also want to create an overall holder JPanel to add the various components to. It is this JPanel that...

  • This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation...

    This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation inside a class. Task One common limitation of programming languages is that the built-in types are limited to smaller finite ranges of storage. For instance, the built-in int type in C++ is 4 bytes in most systems today, allowing for about 4 billion different numbers. The regular int splits this range between positive and negative numbers, but even an unsigned int (assuming 4 bytes)...

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