Initial commit
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package com.example;
|
||||
|
||||
import com.example.util.AddFunction;
|
||||
import com.example.util.CalcFunction;
|
||||
|
||||
public class LoopTestApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("============== Calculator =============");
|
||||
CalcFunction add = new AddFunction();
|
||||
System.out.println("ADDITION: " + add.calc(2, 5, 6));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.example.util;
|
||||
|
||||
public class AddFunction implements CalcFunction {
|
||||
|
||||
public double calc(double... input) {
|
||||
double sum = 0;
|
||||
for (double i : input) {
|
||||
sum += i;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.example.util;
|
||||
|
||||
public interface CalcFunction {
|
||||
|
||||
double calc(double... input);
|
||||
}
|
||||
Reference in New Issue
Block a user