From 7f1fde6c89fe1de1b13f1c80d54f82ae90655799 Mon Sep 17 00:00:00 2001 From: qktlf789456 <54522339+qktlf789456@users.noreply.github.com> Date: Mon, 19 Jun 2023 00:58:01 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20LottoServiceRound=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=8B=9C=20=EB=8F=84=EB=A9=94=EC=9D=B8=20=EC=9D=98?= =?UTF-8?q?=EC=A1=B4=EC=A0=81=EC=9D=B8=20=ED=8C=8C=EB=9D=BC=EB=AF=B8?= =?UTF-8?q?=ED=84=B0=EB=A5=BC=20=EC=82=AC=EC=9A=A9=ED=95=98=EC=A7=80=20?= =?UTF-8?q?=EC=95=8A=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/lotto/domain/LottoServiceRound.kt | 6 +++--- src/main/kotlin/main.kt | 7 ++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/lotto/domain/LottoServiceRound.kt b/src/main/kotlin/lotto/domain/LottoServiceRound.kt index 92a77f4295..2d79b945a9 100644 --- a/src/main/kotlin/lotto/domain/LottoServiceRound.kt +++ b/src/main/kotlin/lotto/domain/LottoServiceRound.kt @@ -5,19 +5,19 @@ import lotto.domain.Money.Companion.toMoney class LottoServiceRound { private val lottoRound = LottoRound(LottoRoundElements()) - fun buyLottos(payment: Money): List { + fun buyLottos(payment: Long): List { lottoRound.addNewLottos(payment.buyableCount()) return lottoRound.getLottos() } - fun allPayment(): Money = (lottoRound.getLottos().size * LOTTO_BUY_PRIZE.value).toMoney() + fun allPayment(): Long = (lottoRound.getLottos().size * LOTTO_BUY_PRIZE.value) fun lotteryDraw(numbers: List): LottoRoundStatistics { val winningLotto = Lotto.of(numbers) return lottoRound.lotteryDraw(winningLotto) } - private fun Money.buyableCount(): Int = (value / LOTTO_BUY_PRIZE.value).toInt() + private fun Long.buyableCount(): Int = (this / LOTTO_BUY_PRIZE.value).toInt() companion object { private val LOTTO_BUY_PRIZE = 1000L.toMoney() diff --git a/src/main/kotlin/main.kt b/src/main/kotlin/main.kt index f5036f4e4c..16022639cf 100644 --- a/src/main/kotlin/main.kt +++ b/src/main/kotlin/main.kt @@ -1,5 +1,4 @@ import lotto.domain.LottoServiceRound -import lotto.domain.Money.Companion.toMoney import lotto.view.LottoInputView import lotto.view.LottoOutputView @@ -11,11 +10,9 @@ fun lotto() { val lottoOutputView = LottoOutputView() val payment = lottoInputView.inputLottoBuy() - lottoServiceRound.buyLottos(payment.toLong().toMoney()).also { - lottoOutputView.currentLottos(it) - } + lottoServiceRound.buyLottos(payment.toLong()).also { lottoOutputView.currentLottos(it) } val winningLottoNumbers = lottoInputView.inputWinningLotto() val lottoRoundStatistics = lottoServiceRound.lotteryDraw(winningLottoNumbers) - lottoOutputView.result(lottoServiceRound.allPayment().value, lottoRoundStatistics) + lottoOutputView.result(lottoServiceRound.allPayment(), lottoRoundStatistics) }