Sum implements Degrees<T> { @Override public Number resolve(final InnerProduct<T> product) { Double sum = 0.; for (final Degrees<T> angle : this.operands) { sum += angle.resolve(product).doubleValue(); } return sum; } Sum(final Iterable<Degrees<T>> operands);  Sum(final Degrees<T> first, final Degrees<T> second); @Override Number resolve(final InnerProduct<T> product);  }
@Test public void resolvesAngleSum() { final Degrees<Object> first = new Degrees.Default<>(Math.random()); final Degrees<Object> second = new Degrees.Default<>(Math.random()); final Degrees<Object> third = new Degrees.Default<>(Math.random()); final InnerProduct<Object> pdt = new MkProduct<>(); final double error = 1.e-6; MatcherAssert.assertThat( new Sum<>(Arrays.asList(first, second, third)).resolve(pdt).doubleValue(), Matchers.closeTo( first.resolve(pdt).doubleValue() + second.resolve(pdt).doubleValue() + third.resolve(pdt).doubleValue(), error ) ); }