-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathInputView.java
More file actions
36 lines (28 loc) · 1.07 KB
/
InputView.java
File metadata and controls
36 lines (28 loc) · 1.07 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 view;
import util.Validation;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import static view.ViewMessage.*;
public class InputView {
private static final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
// 자동차 이름 입력
public static List<String> getCarName() throws IOException {
System.out.println(INPUT_CAR_NAME_MESSAGE.getMessage());
return splitNames(bufferedReader.readLine());
}
// 분리된 자동차 이름 반환
private static List<String> splitNames(String names) {
return Arrays.stream(names.split(SEPARATOR_VALUE.getMessage()))
.map(String::trim)
.collect(Collectors.toList());
}
// 시도 횟수 입력
public static int getTryCount() throws IOException {
System.out.println(TRY_COUNT_MESSAGE.getMessage());
return Validation.parseInteger(bufferedReader.readLine());
}
}