-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathLottoController.java
More file actions
38 lines (30 loc) · 1.51 KB
/
LottoController.java
File metadata and controls
38 lines (30 loc) · 1.51 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
package lotto.controller;
import lotto.domain.*;
import lotto.view.OutputView;
import java.util.Arrays;
import java.util.Map;
public class LottoController {
private static final int LOTTO_PRICE = 1000;
public void lottoStart(){
final int purchaseAmount = InputPurchaseAmount.getPurchaseAmount();
Lotto[] lotto = new Lotto[purchaseAmount];
for (int i = 0; i < purchaseAmount; i++) {
lotto[i] = new Lotto(CreateRandomLottoNumbers.createRandomLottoNumbers());
}
Lottos lottos = new Lottos(Arrays.stream(lotto).toList());
printLottoInformation(purchaseAmount,lottos);
WinningLotto winningLotto = new WinningLotto(InputWinPriceNumber.getWinPriceNumber(), InputWinPriceNumber.getLottoBonusNumber());
Map<WinningRank, Integer> winningDetails = WinningStatistics.getWinningDetails(lottos, winningLotto);
printWinningInformation(winningDetails, purchaseAmount);
}
private void printLottoInformation(int purchaseAmount, Lottos lottos){
InputPurchaseAmount.printPurchaseAmount(purchaseAmount);
Lottos.printLottos(lottos);
}
private void printWinningInformation(Map<WinningRank, Integer> winningDetails, int purchaseAmount) {
OutputView.printWinningStatistics();
OutputView.printWinningDetails(winningDetails);
long winningAmount = WinningStatistics.getWinningAmount(winningDetails);
OutputView.printLottoYield(WinningStatistics.getLottoYield(winningAmount, purchaseAmount*LOTTO_PRICE));
}
}