forked from woowacourse-precourse/java-baseball-6
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDataUtils.java
More file actions
29 lines (25 loc) · 806 Bytes
/
DataUtils.java
File metadata and controls
29 lines (25 loc) · 806 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
28
29
package baseball.utils;
import camp.nextstep.edu.missionutils.Randoms;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class DataUtils {
public static List<Integer> generateRandomNumbers() {
List<Integer> computer = new ArrayList<>();
while (computer.size() < 3) {
int randomNumber = Randoms.pickNumberInRange(1, 9);
if (!computer.contains(randomNumber)) {
computer.add(randomNumber);
}
}
return computer;
}
public static List<Integer> convertToIntList(String input) {
List<Integer> numbers = new ArrayList<>();
for (int i = 0; i < 3; i++) {
numbers.add(input.charAt(i) - '0');
}
return numbers;
}
}