Challenge 2: Implement an Interface
Can you implement an interface in your class? A solution is placed in the solution section to help you, but we would suggest you try to solve it on your own first.
We'll cover the following
Problem Statement
You are given an interface, IAddition
, which contains a method signature int AddTwo(int num1, int num2).
You need to write a class called Calculator
which implements the IAddition
interface.
The AddTwo(int num1, int num2)
method takes two integers and returns their sum.
Input
Calling the AddTwo(int num1, int num2)
method by passing num1
and num2
.
Output
Returns the addition of num1
and num2
.
Sample Input
Calculator cal = new Calculator();
cal.AddTwo(10, 20);
Sample Output
30
Get hands-on with 1400+ tech skills courses.