-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathLottos.java
More file actions
44 lines (34 loc) · 1004 Bytes
/
Lottos.java
File metadata and controls
44 lines (34 loc) · 1004 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package lotto;
import java.util.ArrayList;
import java.util.List;
public class Lottos {
private final List<Lotto> lottos;
public Lottos(List<Lotto> lottos) {
this.lottos = lottos;
}
public static Lottos manualLottos(List<String> manualNumbers) {
return new Lottos(manualNumbers.stream().map(Lotto::new).toList());
}
public Lottos merge(Lottos other) {
List<Lotto> mergedLottos = new ArrayList<>(this.lottos);
mergedLottos.addAll(other.lottos);
return new Lottos(mergedLottos);
}
public int count() {
return lottos.size();
}
public LottoMatchResult matchResult(WinningNumbers winningNumbers) {
LottoMatchResult result = new LottoMatchResult();
for (Lotto lotto : lottos) {
result.match(winningNumbers.matchingRank(lotto));
}
return result;
}
public List<String> toDisplayStrings() {
List<String> lines = new ArrayList<>();
for (Lotto lotto : lottos) {
lines.add(lotto.toString());
}
return lines;
}
}