-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathApplication.java
More file actions
35 lines (26 loc) · 969 Bytes
/
Application.java
File metadata and controls
35 lines (26 loc) · 969 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
27
28
29
30
31
32
33
34
35
package calculator;
import java.util.ArrayList;
public class Application {
private static final Console console = new Console();
public static void main(String[] args) {
String inputString = console.readInput();
run(inputString);
}
public static int run(String inputString) {
Validator validator = new Validator();
Calculator calculator = new Calculator();
ArrayList<String> inputArrayList;
int result = 0;
try {
inputArrayList = validator.divideInput(inputString);
result = calculator.calculate(inputArrayList);
} catch (IllegalStateException e) {
// 입력값이 공백값 또는 비어있는 경우
} catch (IllegalArgumentException illegalArgumentException) {
System.out.println(illegalArgumentException.getMessage());
return -1;
}
console.printResult(result);
return result;
}
}