-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathLottoNumbers.java
More file actions
39 lines (30 loc) Β· 1005 Bytes
/
LottoNumbers.java
File metadata and controls
39 lines (30 loc) Β· 1005 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
package com.hee.domain.number;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class LottoNumbers {
private List<LottoNumber> values;
public static LottoNumbers of(final int from, final int to) {
return new LottoNumbers(from, to);
}
public static LottoNumbers of(final List<Integer> values) {
return new LottoNumbers(values.stream()
.map(LottoNumber::new)
.collect(Collectors.toList()));
}
private LottoNumbers(final int from, final int to) {
this.values = new ArrayList<>();
for (int i = from; i <= to; i++) {
values.add(new LottoNumber(i));
}
}
public LottoNumbers(final List<LottoNumber> values) {
this.values = values;
}
public boolean contains(final LottoNumber lottoNumber) {
return this.values.contains(lottoNumber);
}
public List<LottoNumber> getLottoNumbers() {
return values;
}
}