1
2
3
4
5
6
7
8
9
10public
11class Sum extends Sequence {
12 private
13 long sum;
14
15 private
16 Sequence s;
17
18 public
19 Sum(Sequence s) {
20 this.s = s;
21 this.sum = 0;
22 }
23
24 public
25 long next() {
26 long res = sum;
27
28 sum += s.next();
29
30 return res;
31 }
32}
33
34
35