forked from next-step/java-baseball-precourse
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInputView.java
More file actions
39 lines (35 loc) · 1.13 KB
/
InputView.java
File metadata and controls
39 lines (35 loc) · 1.13 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
37
38
39
package view;
import java.util.Scanner;
public class InputView {
private static final Scanner sc = new Scanner(System.in);
public static String inputCarNames() {
boolean success = false;
String input;
do {
System.out.println("경주할 자동차 이름을 입력하세요.(이름은 쉼표(,) 기준으로 구분)");
input = sc.next();
try {
InputValidator.validateString(input);
success = true;
} catch (IllegalArgumentException e) {
ErrorView.printError(e);
}
} while (!success);
return input;
}
public static String inputRoundNum() {
boolean success = false;
String input;
do {
System.out.println("시도할 회수는 몇회인가요?");
input = sc.next();
try {
InputValidator.validatePositiveNumber(input);
success = true;
} catch (IllegalArgumentException e) {
ErrorView.printError(e);
}
} while (!success);
return input;
}
}