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;
}
}
}
|