-
Notifications
You must be signed in to change notification settings - Fork 134
Expand file tree
/
Copy pathInput.java
More file actions
27 lines (23 loc) · 885 Bytes
/
Input.java
File metadata and controls
27 lines (23 loc) · 885 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
package view;
import java.util.Scanner;
public class Input {
private static final Scanner sc = new Scanner(System.in);
public static String[] getCarName() {
System.out.println("경주할 자동차 이름을 입력하세요. (이름은 쉼표(,) 기준으로 구분)");
return sc.nextLine().split(",");
}
public static int getRound() {
while (true) {
try {
System.out.println("시도할 회수는 몇회인가요?");
int round = Integer.parseInt(sc.nextLine());
if (round <= 0) {
throw new IllegalArgumentException("시도 회수는 양의 정수여야 합니다");
}
return round;
} catch (IllegalArgumentException e) {
System.out.println("[ERROR] " + e.getMessage());
}
}
}
}