-
Notifications
You must be signed in to change notification settings - Fork 275
Expand file tree
/
Copy pathInputView.java
More file actions
36 lines (32 loc) · 1.1 KB
/
Copy pathInputView.java
File metadata and controls
36 lines (32 loc) · 1.1 KB
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
36
package subway.view;
import subway.domain.Errors;
import java.util.List;
import java.util.Scanner;
public class InputView {
public static String inputFunction(Scanner kbd, List<String> functions) {
String input = "0";
try {
System.out.println("\n## 원하는 기능을 선택하세요.");
input = kbd.nextLine();
Errors.checkInput(input, functions);
} catch (Exception e) {
inputFunction(kbd, functions);
}
return input;
}
public static String[] inputSrcDest(Scanner kbd) {
String[] stations = new String[2];
try {
System.out.println("\n## 출발역을 입력하세요.");
stations[0] = kbd.nextLine();
Errors.checkExistStation(stations[0]);
System.out.println("\n## 도착역을 입력하세요.");
stations[1] = kbd.nextLine();
Errors.checkExistStation(stations[1]);
Errors.checkSameName(stations[0], stations[1]);
} catch (Exception e) {
inputSrcDest(kbd);
}
return stations;
}
}