samples/composition/src-api2.0/api/Arithmetica.java
changeset 17 af005434d27f
child 20 afae7be94b25
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/samples/composition/src-api2.0/api/Arithmetica.java	Sat Jun 14 09:51:04 2008 +0200
     1.3 @@ -0,0 +1,23 @@
     1.4 +package api;
     1.5 +
     1.6 +/** Class to simplify arithmetical operations.
     1.7 + *
     1.8 + * @author Jaroslav Tulach <jtulach@netbeans.org>
     1.9 + */
    1.10 +public class Arithmetica {
    1.11 +    public int sumTwo(int one, int second) {
    1.12 +        return one + second;
    1.13 +    }
    1.14 +    
    1.15 +    public int sumAll(int... numbers) {
    1.16 +        int sum = numbers[0];
    1.17 +        for (int i = 1; i < numbers.length; i++) {
    1.18 +            sum = sumTwo(sum, numbers[i]);
    1.19 +        }
    1.20 +        return sum;
    1.21 +    }
    1.22 +    
    1.23 +    public int sumRange(int from, int to) {
    1.24 +        return (from + to) * (from - to + 1) / 2;
    1.25 +    }
    1.26 +}