Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Multiple Inheritance using Interface-Part 1 Create interface 'Engine' & 'Steering' that has been implemented by the given class 'Car'. Write 'getEngine' & 'getStearing' method prototype

Multiple Inheritance using Interface-Part 1

Create interface 'Engine' & 'Steering' that has been implemented by the given class 'Car'. Write 'getEngine' & 'getStearing' method prototype inside 'Engine' & 'Steering' respectively. Both methods should have return type string and not accept any parameter.

Input:

BMW i3

127-kilowatt electric motor

F22 BMW 228i M235i

where

First line contains value of carModel.

Second line contains value of engineModel.

Third lilne contains value of streengModel.

Output:

BMW i3

127-kilowatt electric motor

F22 BMW 228i M235i

where :

First line contains value of carModel.

Second line contains value of engineModel.

Third lilne contains value of streengModel.

Please fill in the partial code below:

using System; using System.Collections.Generic; using System.Linq;

//write your code here

public class Car : Engine, Steering {

private string carModel, engineModel, steeringModel;

public Car (string carModel, string engineModel, string steeringModel) { this.carModel = carModel; this.steeringModel = steeringModel; this.engineModel = engineModel; }

public string getCarModel () { return this.carModel; }

public string getEngine () { return this.engineModel; }

public string getSteering () { return this.steeringModel; } }

class DriverMain {

public static void Main () { string carModel = Console.ReadLine (); string engineModel = Console.ReadLine (); string steeringModel = Console.ReadLine ();

Car car = new Car (carModel, engineModel, steeringModel); Engine engine = car; Steering steering = car;

Console.WriteLine (car.getCarModel ()); Console.WriteLine (car.getEngine ()); Console.WriteLine (car.getSteering ()); } }

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_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions