-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathInputView.java
More file actions
35 lines (29 loc) · 1.2 KB
/
InputView.java
File metadata and controls
35 lines (29 loc) · 1.2 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
package lotto.view;
import lotto.util.Validation;
import org.kokodak.Console;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class InputView {
private static final String PURCHASE_AMOUNT_MESSAGE = "구입 금액을 입력해 주세요.";
private static final String WINNING_NUMBER_MESSAGE = "\n당첨 번호를 입력해 주세요.";
private static final String BONUS_NUMBER_MESSAGE = "\n보너스 번호를 입력해 주세요.";
private static final String SEPARATOR_VALUE = ",";
// 구매 금액 입력
public static int getPurchaseAmount() {
System.out.println(PURCHASE_AMOUNT_MESSAGE);
return Validation.parseInteger(Console.readLine());
}
// 당첨 번호 입력
public static List<Integer> getLottoNumbers() {
System.out.println(WINNING_NUMBER_MESSAGE);
return Arrays.stream(Console.readLine().split(SEPARATOR_VALUE))
.map(Validation::parseInteger)
.collect(Collectors.toList());
}
// 보너스 번호 입력
public static int getBonusNumber() {
System.out.println(BONUS_NUMBER_MESSAGE);
return Validation.parseInteger(Console.readLine());
}
}