-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathLottoController.java
More file actions
33 lines (26 loc) · 1.3 KB
/
LottoController.java
File metadata and controls
33 lines (26 loc) · 1.3 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
package lotto.controller;
import lotto.View.InputView;
import lotto.View.OutputView;
import lotto.domain.*;
import lotto.service.LottoGenerator;
import lotto.service.WinningDetails;
import lotto.service.WinningRank;
import java.util.Map;
public class LottoController {
public void lottoStart() {
try {
int money = InputView.getPurchaseAmount(); //금액 입력
LottoGenerator lottoGenerator = new LottoGenerator(money);
Lottos lottos = new Lottos(lottoGenerator.generateLottos()); //개수만큼 로또 생성
OutputView.printHowManyLottoUserPurchased(lottoGenerator.getLottoQuantity());
OutputView.printLottos(lottos); //구매 개수랑 출력
LottoWinningNumber lottoWinningNumber = new LottoWinningNumber(InputView.getWinningNums(), InputView.getBonusNum());
Map<WinningRank, Integer> winningDetails = WinningDetails.getWinningDetails(lottos, lottoWinningNumber);
OutputView.printWinningDetails(winningDetails);
long profit = WinningDetails.getProfit(winningDetails);
OutputView.printProfitRate(WinningDetails.getProfitRate(profit, money)); //당첨결과, 수익률
} catch (IllegalArgumentException e) {
System.out.println(e.getMessage());
}
}
}