forked from knh4437/java-lotto
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLottos.java
More file actions
34 lines (26 loc) · 930 Bytes
/
Lottos.java
File metadata and controls
34 lines (26 loc) · 930 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
package lotto.domain;
import lotto.domain.generator.LottoGenerator;
import lotto.domain.result.LottoResult;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class Lottos {
private final List<Lotto> lottos;
public Lottos(List<Lotto> lottos) {
this.lottos = new ArrayList<>(lottos);
}
public static Lottos from(LottoGenerator lottoGenerator, int quantity) {
return new Lottos(Stream.generate(() -> Lotto.from(lottoGenerator))
.limit(quantity)
.collect(Collectors.toList()));
}
public List<LottoResult> compare(Lotto winningLotto, int bonusNumber) {
return lottos.stream()
.map(lotto -> lotto.getResult(winningLotto, bonusNumber))
.collect(Collectors.toList());
}
public List<Lotto> getLottos() {
return lottos;
}
}