Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!