-
Notifications
You must be signed in to change notification settings - Fork 107
Expand file tree
/
Copy pathLottos.java
More file actions
33 lines (24 loc) · 949 Bytes
/
Lottos.java
File metadata and controls
33 lines (24 loc) · 949 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
package Model;
import View.InputData;
import java.util.ArrayList;
import java.util.List;
public class Lottos {
private ArrayList<Lotto> lottos = new ArrayList<>();
public void addNewLotto(Lotto lotto){
lottos.add(lotto);
}
public ArrayList<Lotto> getLottos() {
return lottos;
}
public int[] matchList(Lotto firstLotto, int bonus){
int[] matchList = new int[5];
List<Integer> answerLotto = firstLotto.getLottoNumbers().stream().map(LottoNumber::getNumber).toList();
for (Lotto lotto:lottos) {
List<Integer> buyLotto = lotto.getLottoNumbers().stream().map(LottoNumber::getNumber).toList();
int matchCount = (int) buyLotto.stream().filter(answerLotto::contains).count();
boolean bonusResult = buyLotto.contains(bonus);
DataEnum.LottoResult.applyResult(matchList,matchCount,bonusResult);
}
return matchList;
}
}