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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started