-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path6.2.java
More file actions
26 lines (20 loc) · 779 Bytes
/
6.2.java
File metadata and controls
26 lines (20 loc) · 779 Bytes
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
public class Handler {
public int handleResults(String input) {
int result = 0;
if (input.contains("error")) throw new HandlerException();
if (input.length()==0 || input == null) throw new NullHandlerException();
try{
String[] numbers = input.split("\\.");
result = Integer.parseInt(numbers[0])+Integer.parseInt(numbers[1])-(Integer.parseInt(numbers[2])*Integer.parseInt(numbers[3]));
} catch(RuntimeException t){
}
if (result<0) throw new HandlerResultException();
return result;
}
class HandlerException extends RuntimeException {
}
class HandlerResultException extends RuntimeException{
}
class NullHandlerException extends RuntimeException{
}
}