-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathAdjustmentLotto.java
More file actions
43 lines (35 loc) · 1.17 KB
/
AdjustmentLotto.java
File metadata and controls
43 lines (35 loc) · 1.17 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
39
40
41
42
43
package lotto.service;
import lotto.model.Lotto;
import java.util.ArrayList;
import java.util.List;
public class AdjustmentLotto {
private int[] lotto = new int[5];
private List<Lotto> lottoList = new ArrayList<Lotto>();
private int bonus;
public AdjustmentLotto(List<Lotto> lottoList, int bonus) {
this.lottoList = lottoList;
this.bonus = bonus;
for (int l : lotto) { lotto[l] = 0; }
}
public int[] getLotto() {
return lotto;
}
public void countCorrectNumber(){
for (Lotto l : lottoList){
countCorrectNumber(l);
}
}
public void countCorrectNumber(Lotto winningLotto) {
if (winningLotto.getCorrectNumbers() == 3) { lotto[0]++; }
if (winningLotto.getCorrectNumbers() == 4) { lotto[1]++; }
if (winningLotto.getCorrectNumbers() == 5) {
CountCorrectNumber countCorrectNumber = new CountCorrectNumber(lottoList);
if (countCorrectNumber.sameNumber(winningLotto, bonus)){
lotto[3]++;
return;
}
lotto[4]++;
}
if (winningLotto.getCorrectNumbers() == 6) { lotto[4]++; }
}
}