/** * Copyright (c): Uwe Schmidt, FH Wedel * * You may study, modify and distribute this source code * FOR NON-COMMERCIAL PURPOSES ONLY. * This copyright message has to remain unchanged. * * Note that this document is provided 'as is', * WITHOUT WARRANTY of any kind either expressed or implied. */ public class AddFunctions implements RealFunction { private RealFunction f1; private RealFunction f2; public AddFunctions(RealFunction f1, RealFunction f2) { this.f1 = f1; this.f2 = f2; } public double at(double x) { return f1.at(x) + f2.at(x); } public String toString() { return "(" + f1.toString() + " + " + f2.toString() + ")"; } }