Question: C# programing Interface implementation Create and implement an interface. Create a Car interface with following characteristics Method displaySpeed with no parameter and void return type.
C# programing
Interface implementation
Create and implement an interface.
Create a Car interface with following characteristics
Method displaySpeed with no parameter and void return type.
Method increaseSpeed with an integer as a parameter and void return type.
Create a Suzuki class with following characteristics
Must implement interface Car.
Member variable as currentSpeed of type integer.
Initialize member variable of the class using parameterized constructor the class.
Method increaseSpeed to add speed parameter to currentSpeed.
Method displaySpeed prints the currentSpeed of the car.
Input 10 20
where
First line contains value currentSpeed.
Second line contains value of speed.
Output 30
Please fill in the partial code below:
using System; using System.Collections.Generic; using System.Linq;
//write your code here
interface Car { void increaseSpeed (int speed); void displaySpeed (); }
class DriverMain {
public static void Main () { int currentSpeed = int.Parse (Console.ReadLine ()); int speed = int.Parse (Console.ReadLine ()); Car car = new Suzuki (currentSpeed); car.increaseSpeed (speed); car.displaySpeed (); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
