summaryrefslogtreecommitdiff
path: root/java/12-error-handling-2/Maths.java
blob: b61a9f2a85170884f9875753f2bcdc0401753f99 (plain)
1
2
3
4
5
6
7
8
9
10
11
public class Maths {
	
	public int factorial(int number) throws MathsException {
		if (number < 0) {
			MathsException e = new MathsException("Factorial of " + number + " not defined");
//			e.setX(100);
			throw e;
		}
		return number == 0 ? 1 : number * factorial(number - 1); 
	}
}