Fixing the optimized 2.0 implementation and adding yet another test for factorial of 4
1.1 --- a/samples/composition/src-api1.0/api/Arithmetica.java Sat Jun 14 09:51:04 2008 +0200
1.2 +++ b/samples/composition/src-api1.0/api/Arithmetica.java Sat Jun 14 09:51:05 2008 +0200
1.3 @@ -3,6 +3,7 @@
1.4 /** Class to simplify arithmetical operations.
1.5 *
1.6 * @author Jaroslav Tulach <jtulach@netbeans.org>
1.7 + * @version 1.0
1.8 */
1.9 public class Arithmetica {
1.10 public int sumTwo(int one, int second) {
2.1 --- a/samples/composition/src-api2.0/api/Arithmetica.java Sat Jun 14 09:51:04 2008 +0200
2.2 +++ b/samples/composition/src-api2.0/api/Arithmetica.java Sat Jun 14 09:51:05 2008 +0200
2.3 @@ -1,8 +1,10 @@
2.4 package api;
2.5
2.6 -/** Class to simplify arithmetical operations.
2.7 +/** Class to simplify arithmetical operations, improved version to compute
2.8 + * the sum for ranges.
2.9 *
2.10 * @author Jaroslav Tulach <jtulach@netbeans.org>
2.11 + * @version 2.0
2.12 */
2.13 public class Arithmetica {
2.14 public int sumTwo(int one, int second) {
2.15 @@ -18,6 +20,6 @@
2.16 }
2.17
2.18 public int sumRange(int from, int to) {
2.19 - return (from + to) * (from - to + 1) / 2;
2.20 + return (from + to) * (to - from + 1) / 2;
2.21 }
2.22 }
3.1 --- a/samples/composition/src-test/api/FactorialTest.java Sat Jun 14 09:51:04 2008 +0200
3.2 +++ b/samples/composition/src-test/api/FactorialTest.java Sat Jun 14 09:51:05 2008 +0200
3.3 @@ -31,6 +31,10 @@
3.4 assertEquals(6, Factorial.factorial(3));
3.5 }
3.6
3.7 + public void testFactorial4() {
3.8 + assertEquals(24, Factorial.factorial(4));
3.9 + }
3.10 +
3.11 public void testFactorial5() {
3.12 assertEquals(120, Factorial.factorial(5));
3.13 }