Example.java :  » Test-Coverage » Hansel » org » hanselexample » Java Open Source

Java Open Source » Test Coverage » Hansel 
Hansel » org » hanselexample » Example.java
package org.hanselexample;

/**
 * Example class that is tested by the ExampleTest class.
 * This implements two methods and has one inner class.
 *
 * @author Niklas Mehner
 */
public class Example {

    /**
     * The method returns the absolute value of an int.
     * @param i Int.
     * @return Absolute value of i.
     */
    public int abs(int i) {
        if (i > 0) {
            return i;
        } else {
            return -i;
        }
    }
 
    /**
     * This method returns the sum of two numbers.
     * @param a First addend.
     * @param b Second addend.
     * @return Sum of a and b.
     */
    public int add(int a, int b) {
        return new ExampleInner().add(a, b);
    }

    /**
     * The add method delegates the call to this class to
     * test the coverage of inner classes.
     */
    private class ExampleInner {
       
        /**
         * This method returns the sum of two numbers.
         * @param a First addend.
         * @param b Second addend.
         * @return Sum of a and b.
         */
       public int add(int a, int b) {
            return a + b;
       }
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.