forked from next-step/java-lotto
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLottoGameController.java
More file actions
41 lines (31 loc) · 1.39 KB
/
LottoGameController.java
File metadata and controls
41 lines (31 loc) · 1.39 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
package step2.controller;
import step2.domain.LottoTicket;
import step2.domain.LottoGames;
import step2.domain.LottoResultReport;
import step2.view.InputView;
import step2.view.ResultView;
import java.util.List;
public class LottoGameController {
private LottoGames lottoGames = new LottoGames();
public void playLottoGame() {
int money = InputView.readAmountOfPurchase();
int gameCount = lottoGames.calculateBuyingTicketCount(money);
ResultView.printMessage(gameCount + "개를 구매했습니다.");
if (gameCount == 0) {
return;
}
List<LottoTicket> lottoTickets = lottoGames.buyLottoGame(gameCount);
ResultView.printLottoTicket(lottoTickets);
LottoTicket winningTicket = lottoGames.readWinningNumber(InputView.readWinningNumbers());
int bonusNumber = InputView.readBonusNumber();
ResultView.printBlankLine();
ResultView.printMessage("당첨 통계");
LottoResultReport lottoResultReport = new LottoResultReport();
for (LottoTicket lottoTicket : lottoTickets) {
lottoResultReport.recordRank(lottoTicket.checkLottoTicket(winningTicket, bonusNumber));
}
ResultView.printResultReport(lottoResultReport);
double profit = lottoResultReport.calculateProfit(gameCount);
ResultView.printMessage("총 수익률은 " + profit + "입니다.");
}
}