-
Notifications
You must be signed in to change notification settings - Fork 0
/
Verify.java
33 lines (27 loc) · 896 Bytes
/
Verify.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package unit10.mySolutions;
import unit10.solutions.NumberHighException;
import unit10.solutions.NumberLowException;
import unit10.solutions.NumberNegativeException;
//Re-throws exceptions in Verify class and catches them in main method.
public class Verify {
int number = 0;
public void verifyNumber(int n) throws
NumberHighException, NumberLowException, NumberNegativeException {
checkNumber(n);
}
public void checkNumber(int n)
throws NumberHighException, NumberLowException {
checkHighLow(n);
}
public void checkHighLow(int n)
throws NumberLowException, NumberHighException {
if(n < 0)
throw new NumberNegativeException("number < 0");
else if(n < 10)
throw new NumberLowException("number < 10");
else if(n > 100)
throw new NumberHighException("number > 100");
else
number = n;
}
}