-
Notifications
You must be signed in to change notification settings - Fork 589
Expand file tree
/
Copy pathApp.js
More file actions
50 lines (32 loc) · 1.25 KB
/
App.js
File metadata and controls
50 lines (32 loc) · 1.25 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
import { MissionUtils } from '@woowacourse/mission-utils';
import Converter from './Converter/Converter.js';
import Lotto from './Lotto/Lotto.js';
import LottoIntergrator from './Lotto/LottoIntergrator.js';
import Receiver from './Receiver/Receiver.js';
import Validator from './Validator/Validator.js';
import Printer from './Printer/Printer.js';
class App {
#userMoney;
#userSetLottoNums;
#bonusNum;
#lottos = new LottoIntergrator();
async play() {
this.#userMoney = await Receiver.receiveMoney();
Validator.checkPurchaseAmount(this.#userMoney);
this.#userMoney /= 1000;
this.generateLottos();
Printer.printPublishInfo(this.#userMoney, this.#lottos.allLottoInfo());
this.#userSetLottoNums = Converter.stringToArray(await Receiver.receiveLottomNums());
Validator.checkLottoNums(this.#userSetLottoNums);
this.#bonusNum = await Receiver.receiveBonusNum();
Validator.checkBonusNum(this.#bonusNum);
console.log(this.#lottos.saveBoard(this.#userSetLottoNums, this.#bonusNum));
}
generateLottos() {
for (let i = 0; i < this.#userMoney; i += 1) {
const lotto = MissionUtils.Random.pickUniqueNumbersInRange(1, 45, 6);
this.#lottos.pushLotto(new Lotto(lotto).getLotto());
}
}
}
export default App;