forked from knh4437/java-lotto
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathLotto.java
More file actions
35 lines (28 loc) · 937 Bytes
/
Lotto.java
File metadata and controls
35 lines (28 loc) · 937 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
package lotto.model;
import java.util.List;
import static lotto.util.LottoValidator.validateNumbers;
public class Lotto {
private final List<Integer> numbers;
public Lotto(List<Integer> numbers) {
validateNumbers(numbers);
this.numbers = numbers;
}
/**
* 특정 번호가 로또 번호 리스트에 포함되어 있는지 확인
*/
public boolean contains(int number) {
return numbers.contains(number);
}
/**
* 당첨 번호 리스트와 로또 번호 리스트의 일치 개수를 반환
*/
public int matchCount(List<Integer> winningNumbers) {
return (int) numbers.stream().filter(winningNumbers::contains).count(); //numbers에 있는 int를 loop 돌려서 winningNumbers에 포함되어있다면 개수를 셈
}
/**
* 로또 번호 리스트 반환
*/
public List<Integer> getNumbers() {
return numbers;
}
}