samples/composition/src-api2.0/api/Arithmetica.java
author Jaroslav Tulach <jtulach@netbeans.org>
Sat, 14 Jun 2008 09:51:04 +0200
changeset 17 af005434d27f
child 20 afae7be94b25
permissions -rw-r--r--
Converting to ant freeform script as it allows to demonstrate the amoeba effect
     1 package api;
     2 
     3 /** Class to simplify arithmetical operations.
     4  *
     5  * @author Jaroslav Tulach <jtulach@netbeans.org>
     6  */
     7 public class Arithmetica {
     8     public int sumTwo(int one, int second) {
     9         return one + second;
    10     }
    11     
    12     public int sumAll(int... numbers) {
    13         int sum = numbers[0];
    14         for (int i = 1; i < numbers.length; i++) {
    15             sum = sumTwo(sum, numbers[i]);
    16         }
    17         return sum;
    18     }
    19     
    20     public int sumRange(int from, int to) {
    21         return (from + to) * (from - to + 1) / 2;
    22     }
    23 }