-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathLottoApplication.java
More file actions
59 lines (49 loc) · 2.5 KB
/
LottoApplication.java
File metadata and controls
59 lines (49 loc) · 2.5 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
55
56
57
58
package lotto;
import lotto.domain.LottoMachine;
import lotto.domain.Profit;
import lotto.domain.WinningStatus;
import lotto.domain.lastweekwinninglotto.LastWeekWinningBonusBall;
import lotto.domain.lastweekwinninglotto.LastWeekWinningLotto;
import lotto.domain.lottoticket.LottoTicket;
import lotto.domain.lottoticket.Lottos;
import lotto.domain.lottoticket.NumberOfLottoTicket;
import lotto.domain.strategy.RandomLottoNumberStrategy;
import lotto.ui.Printer;
import lotto.ui.Receiver;
import java.util.ArrayList;
import java.util.List;
public class LottoApplication {
private final Printer printer = new Printer();
private final Receiver receiver = new Receiver();
private static LottoMachine lottoMachine = new LottoMachine();
private final RandomLottoNumberStrategy randomLottoNumberStrategy = new RandomLottoNumberStrategy();
public void run() {
printer.requestPurchaseAmount();
NumberOfLottoTicket numberOfLottoTicket = new NumberOfLottoTicket(receiver.receiveLottoTotalAmount());
printer.printNumberOfLottoTicket(numberOfLottoTicket);
Lottos lottos = makeLottos(numberOfLottoTicket);
printer.printAllLotto(lottos);
printer.requestLastWeekLottoWinningNumber();
List<Integer> LastWeekLottoWinningNumbers = receiver.receiveLastWeekLottoWinningNumbers();
LastWeekWinningLotto lastWeekWinningLotto = new LastWeekWinningLotto(LastWeekLottoWinningNumbers);
printer.requestLottoBonusBallNumber();
LastWeekWinningBonusBall lastWeekWinningBonusBall = new LastWeekWinningBonusBall(receiver.receiveLottoBonusBallNumber(), lastWeekWinningLotto);
ArrayList<WinningStatus> getLottoPrices = lottoMachine.Discriminator(lottos, lastWeekWinningLotto, lastWeekWinningBonusBall, numberOfLottoTicket);
Profit profit = new Profit(getLottoPrices, numberOfLottoTicket);
printer.printLottoProfit(profit.getProfit());
printer.printIsLottoProfit(profit.isProfit());
}
private Lottos makeLottos(NumberOfLottoTicket numberOfLottoTicket) {
ArrayList<LottoTicket> lottoDummy = new ArrayList<>();
for (int i = 0; i < numberOfLottoTicket.getNumberOfLottoTicket(); i++) {
LottoTicket lotto = new LottoTicket(randomLottoNumberStrategy.getRandomLottoNumbers());
lottoDummy.add(lotto);
}
Lottos lottos = new Lottos(lottoDummy);
return lottos;
}
public static void main(String[] args) {
LottoApplication app = new LottoApplication();
app.run();
}
}