Code Monkey home page Code Monkey logo

19ai308-object-oriented-programming-using-csharp--ex7---hierarchical-inheritance's Introduction

19AI308-Object-Oriented-Programming-using-CSharp--Ex7---Hierarchical-Inheritance

AIM :

To write a C# program to implement heirarchical inheritance for the following problem statement: All the vehicles need Tyres on their wheels. So, the manufacturer designs their vehicle as they want and import Tyre from its base class and fit it into Wheels. They don’t need to design Tyre all the time. Once they designed the model and use it various times. Aim is to create a Scooter and Car vehicle where the Tyre is being inherited from vehicle class.

ALGORITHM :

Step 1 :

Define a base class 'Vehicle' with a method 'tyre' to describe tyres.

Step 2 :

Create a 'Scooter' class inheriting 'Vehicle', with a method 'Display' and 'tyres'.

Step 3 :

Implement 'Display' to show class type and call base 'tyre'.

Step 4 :

Similarly, make a 'Car' class inheriting 'Vehicle', with a 'Display' method.

Step 5 :

Instantiate Car' and 'Scooter', call 'Display' with respective tyre counts.

PROGRAM :

DEVELOPED BY : THRIKESWAR P

REG NO : 212222230162

using System;

public class Vechicle
{
    public void tyre()
    {
        Console.WriteLine("It is a tubeless tyre");
    }
}

class Scooter : Vechicle
{
    public  void display() 
    {
        base.tyre();
        Console.WriteLine("It is a scooter class");
    }
}

class Car : Vechicle
{
    public  void display() 
    {
        base.tyre();
        Console.WriteLine("It is a car class");
    }
}

class Program
{
    static void Main()
    {
        Scooter scooter = new Scooter();
        Car car = new Car();
        
        
        Console.WriteLine("Scooter started:");
        scooter.display();
        
        Console.WriteLine("\nCar started:");
        car.display();
    }
}

OUTPUT :

Screenshot 2024-04-22 221058

RESULT :

Thus the program has been executed successfully.

19ai308-object-oriented-programming-using-csharp--ex7---hierarchical-inheritance's People

Contributors

aswini-j avatar thrikesh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.