Splitting Factorial into own class, so Andrei does not need to complain about it having static modifier
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/samples/composition/src-test/api/Factorial.java Sat Jun 14 10:04:45 2008 +0200
1.3 @@ -0,0 +1,18 @@
1.4 +package api;
1.5 +
1.6 +/** Class showing inventive, non-expected use of
1.7 + * Arithmetica methods to do multiplication instead of
1.8 + * addition.
1.9 + */
1.10 +//BEGIN: design.composition.arith.factorial
1.11 +public final class Factorial extends Arithmetica {
1.12 + public static int factorial(int n) {
1.13 + return new Factorial().sumRange(1, n);
1.14 + }
1.15 + @Override
1.16 + public int sumTwo(int one, int second) {
1.17 + return one * second;
1.18 + }
1.19 +}
1.20 +//END: design.composition.arith.factorial
1.21 +
2.1 --- a/samples/composition/src-test/api/FactorialTest.java Sat Jun 14 10:04:41 2008 +0200
2.2 +++ b/samples/composition/src-test/api/FactorialTest.java Sat Jun 14 10:04:45 2008 +0200
2.3 @@ -38,22 +38,4 @@
2.4 public void testFactorial5() {
2.5 assertEquals(120, Factorial.factorial(5));
2.6 }
2.7 -
2.8 - /** Class showing inventive, non-expected use of
2.9 - * Arithmetica methods to do multiplication instead of
2.10 - * addition.
2.11 - */
2.12 - //BEGIN: design.composition.arith.factorial
2.13 - public static final class Factorial extends Arithmetica {
2.14 - public static int factorial(int n) {
2.15 - return new Factorial().sumRange(1, n);
2.16 - }
2.17 - @Override
2.18 - public int sumTwo(int one, int second) {
2.19 - return one * second;
2.20 - }
2.21 - }
2.22 - //END: design.composition.arith.factorial
2.23 -
2.24 -
2.25 }