class Sum<T extends Number> {
private T t1, t2;
Sum(T t1, T t2) {
this.t1 = t1;
this.t2 = t2;
}
public T sum() {
return (T)(new Double(t1.doubleValue() + t2.doubleValue());
}
}
public class TestTask<T extends Number> {
private Calc<T> calc;
private T t1;
private T t2;
public TestTask(T t1, T t2) {
this.t1 = t1;
this.t2 = t2;
}
public T sum(T a, T b) {
return calc.sum(a, b);
}
}
interface Calc<T extends Number> {
T sum(T a, T b);
}
class DoubleCalc implements Calc<Double> {
@Override
public Double sum(Double a, Double b) {
return a+b;
}
}