-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathLottoSeller.java
More file actions
38 lines (30 loc) Β· 918 Bytes
/
LottoSeller.java
File metadata and controls
38 lines (30 loc) Β· 918 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
package domain.provider;
import domain.lotto.Lotto;
import domain.lotto.LottoCollection;
import domain.money.Money;
import java.util.ArrayList;
import java.util.List;
/**
* @author delf
*/
public class LottoSeller {
private Money lotto;
private LottoGenerator lottoGenerator = new LottoGenerator(); // νμ¬λ κ³ μ
public LottoSeller(Money lottoPrice) {
this.lotto = lottoPrice;
}
public LottoCollection sellTo(Money money) {
int buyLottoSize = getCountOfLotto(money);
return generateLottoCollection(buyLottoSize);
}
private int getCountOfLotto(Money money) {
return Money.of(money).getAmount() / lotto.getAmount();
}
private LottoCollection generateLottoCollection(/* λ‘λ μμ± μ λ΅ ,*/ int size) {
List<Lotto> lottoList = new ArrayList<>();
for (int i = 0; i < size; i++) {
lottoList.add(lottoGenerator.generateLotto());
}
return new LottoCollection(lottoList);
}
}