Skip to content

Commit

Permalink
refactor: remove isResultCalculated logic
Browse files Browse the repository at this point in the history
  • Loading branch information
zigsong committed Feb 27, 2021
1 parent b140cd6 commit 146b3e0
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/js/LottoController.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export default class LottoController {
reset() {
this.lottos = [];
this.purchasedPrice = 0;
this.isResultCalculated = false;

this.inputPriceView.show().resetInputPrice();
this.purchasedLottosView.hide().resetToggleSwitch();
Expand Down Expand Up @@ -66,18 +65,14 @@ export default class LottoController {
}

inputNumbersHandler(winningNumbers) {
console.log(winningNumbers);
if (!isUniqueWinningNumber(winningNumbers)) {
alert(ALERT_MESSAGES.DUPLICATE_NUMS);
return;
}

const lottoProcessor = new LottoProcessor(this.lottos, winningNumbers);
if (!this.isResultCalculated) {
lottoProcessor.checkMatchingNums();
lottoProcessor.calculateEarningRate(this.purchasedPrice);
this.isResultCalculated = true;
}
lottoProcessor.checkMatchingNums();
lottoProcessor.calculateEarningRate(this.purchasedPrice);

this.winningResultView.showModal(
lottoProcessor.rankCounts,
Expand Down

0 comments on commit 146b3e0

Please sign in to comment.