-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathLottoApplication.java
More file actions
54 lines (47 loc) · 1.78 KB
/
LottoApplication.java
File metadata and controls
54 lines (47 loc) · 1.78 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
53
54
import java.util.ArrayList;
import java.util.List;
import domain.LottoNumber;
import domain.Lotto;
import domain.LottoCount;
import domain.Lottos;
import domain.Money;
import domain.ProfitResult;
import domain.WinningLotto;
import ui.Receiver;
import ui.Printer;
public class LottoApplication {
Printer printer = new Printer();
Receiver receiver = new Receiver();
public static void main(String[] args) {
LottoApplication app = new LottoApplication();
app.start();
}
private void start() {
LottoCount count = getCountByMoney();
List<String> manualLottoNumbers = getManualLottoNumbers(count);
printer.printNumberOfLottoTickets(count);
Lottos lottos = Lottos.createLottos(manualLottoNumbers, count);
printer.printLottos(lottos);
WinningLotto winningLotto = getWinningLotto();
ProfitResult result = winningLotto.getResult(lottos);
printer.printLottoProfit(result);
printer.printIsLottoProfit(result.isProfit());
}
private List<String> getManualLottoNumbers(LottoCount count) {
List<String> manualLottoNumbers = new ArrayList<>();
if (count.hasManualLottoCount()) {
manualLottoNumbers.addAll(receiver.receiveManualLottoNumbers(count));
}
return manualLottoNumbers;
}
private LottoCount getCountByMoney() {
int inputMoney = receiver.receiveMoney();
Money money = new Money(inputMoney);
return money.getLottoCount(receiver.receiveManualNumberOfLottoTickets());
}
private WinningLotto getWinningLotto() {
Lotto winningLotto = Lotto.of(receiver.receiveWinningLottoNumbers());
LottoNumber bonusBall = LottoNumber.of(receiver.receiveBonusBall());
return new WinningLotto(winningLotto, bonusBall);
}
}