samples/composition/src-test/api/Factorial.java
author Jaroslav Tulach <jtulach@netbeans.org>
Sat, 14 Jun 2008 10:04:45 +0200
changeset 207 675393d7093a
child 235 cfcf2129865f
permissions -rw-r--r--
Splitting Factorial into own class, so Andrei does not need to complain about it having static modifier
     1 package api;
     2 
     3 /** Class showing inventive, non-expected use of 
     4  * Arithmetica methods to do multiplication instead of
     5  * addition.
     6  */
     7 //BEGIN: design.composition.arith.factorial
     8 public final class Factorial extends Arithmetica {
     9     public static int factorial(int n) {
    10         return new Factorial().sumRange(1, n);
    11     }
    12     @Override
    13     public int sumTwo(int one, int second) {
    14         return one * second;
    15     }
    16 }
    17 //END: design.composition.arith.factorial
    18