-
Notifications
You must be signed in to change notification settings - Fork 591
Expand file tree
/
Copy pathLottoFlow.js
More file actions
41 lines (35 loc) · 1.12 KB
/
LottoFlow.js
File metadata and controls
41 lines (35 loc) · 1.12 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
import InputView from '../views/InputView.js';
import OutputView from '../views/OutputView.js';
import Lotto from '../Lotto.js';
import Seller from '../models/Seller.js';
import ResultAnalyzer from '../models/ResultAnalyzer.js';
class LottoFlow {
#seller;
#lotto;
#resultAnalizer;
constructor() {
this.#seller = new Seller();
}
async makeLotto() {
const money = await InputView.InputMoney();
this.#seller.setAmount(money);
const { winningNumber, bonusNumber, ticketList } =
await this.#seller.makeWinnigNumber();
await this.processLotto(winningNumber, bonusNumber, ticketList);
}
async processLotto(winningNumber, bonusNumber, ticketList) {
this.#lotto = new Lotto(winningNumber, ticketList);
await this.#lotto.confirmNumber(bonusNumber);
this.endLotto(winningNumber, bonusNumber, ticketList);
}
endLotto(winningNumber, bonusNumber, ticketList) {
this.#resultAnalizer = new ResultAnalyzer(
winningNumber,
bonusNumber,
ticketList,
);
const result = this.#resultAnalizer.findResult();
OutputView.printResult(result);
}
}
export default LottoFlow;