-
Notifications
You must be signed in to change notification settings - Fork 738
Expand file tree
/
Copy pathResultInfo.java
More file actions
38 lines (28 loc) · 1.04 KB
/
ResultInfo.java
File metadata and controls
38 lines (28 loc) · 1.04 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
package nextstep.ladder.domain;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class ResultInfo {
private final List<String> results;
public ResultInfo(String result, int participantCount) {
this(checkResultSize(Arrays.stream(result.split(",")).collect(Collectors.toList()), participantCount));
}
private static List<String> checkResultSize(List<String> result, int participantCount) {
checkResultAndParticipantCount(result, participantCount);
return result;
}
public ResultInfo(List<String> results) {
this.results = results;
}
private static void checkResultAndParticipantCount(List<String> result, int participantCount) {
if (result.size() != participantCount) {
throw new IllegalArgumentException("결과 갯수와 참가자 수와 다릅니다.");
}
}
public List<String> getResults() {
return results;
}
public String getResult(int position) {
return results.get(position);
}
}