author | Jaroslav Tulach <jtulach@netbeans.org> |
Sat, 14 Jun 2008 10:08:14 +0200 | |
changeset 245 | ce3b323add40 |
parent 244 | 2b19d24a755f |
permissions | -rw-r--r-- |
jtulach@207 | 1 |
package api; |
jtulach@207 | 2 |
|
jtulach@207 | 3 |
/** Class showing inventive, non-expected use of |
jtulach@207 | 4 |
* Arithmetica methods to do multiplication instead of |
jtulach@207 | 5 |
* addition. |
jtulach@207 | 6 |
*/ |
jtulach@245 | 7 |
// BEGIN: design.composition.arith.factorial |
jtulach@207 | 8 |
public final class Factorial extends Arithmetica { |
jtulach@207 | 9 |
public static int factorial(int n) { |
jtulach@207 | 10 |
return new Factorial().sumRange(1, n); |
jtulach@207 | 11 |
} |
jtulach@207 | 12 |
@Override |
jtulach@207 | 13 |
public int sumTwo(int one, int second) { |
jtulach@207 | 14 |
return one * second; |
jtulach@207 | 15 |
} |
jtulach@207 | 16 |
} |
jtulach@245 | 17 |
// END: design.composition.arith.factorial |
jtulach@207 | 18 |