1public
2class AddFunctions
3 implements RealFunction
4{
5 private
6 RealFunction f1;
7
8 private
9 RealFunction f2;
10
11 public
12 AddFunctions(RealFunction f1, RealFunction f2) {
13 this.f1 = f1;
14 this.f2 = f2;
15 }
16
17 public
18 double at(double x) {
19 return
20 f1.at(x) + f2.at(x);
21 }
22
23 public
24 String toString() {
25 return
26 "(" + f1.toString() + " + " + f2.toString() + ")";
27 }
28}
29