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) }