-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathLottoCount.java
More file actions
52 lines (42 loc) · 1.26 KB
/
LottoCount.java
File metadata and controls
52 lines (42 loc) · 1.26 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
44
45
46
47
48
49
50
51
52
package domain;
import java.util.Objects;
public class LottoCount {
private static final int MINIMUM_MANUAL_LOTTO_COUNT = 0;
private final int manualLottoCount;
private final int lottoCount;
public LottoCount(int lottoCount) {
this(lottoCount, MINIMUM_MANUAL_LOTTO_COUNT);
}
public LottoCount(int lottoCount, int manualLottoCount) {
this.lottoCount = lottoCount;
this.manualLottoCount = manualLottoCount;
}
public boolean hasManualLottoCount() {
return manualLottoCount != 0;
}
public Money getBuyMoney(int lottoPrice) {
return new Money(lottoCount * lottoPrice);
}
public int getAutoLottoCount() {
return lottoCount - manualLottoCount;
}
public int getManualLottoCount() {
return manualLottoCount;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
LottoCount that = (LottoCount) o;
return manualLottoCount == that.manualLottoCount &&
lottoCount == that.lottoCount;
}
@Override
public int hashCode() {
return Objects.hash(manualLottoCount, lottoCount);
}
}