Skip to content

Commit

Permalink
feat: done on main
Browse files Browse the repository at this point in the history
  • Loading branch information
qktlf789456 committed Jun 19, 2023
1 parent 09a0b12 commit 2dc324a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/lotto/view/LottoInputView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class LottoInputView {

fun inputWinningLotto(): List<Int> {
println(WINNING_LOTTO_COMMENT)
return readLineOrThrows().split(",").map { it.toInt() }
return readLineOrThrows().replace(" ", "").split(",").map { it.toInt() }
}

private fun readLineOrThrows(): String = readLine() ?: throw IllegalArgumentException()
Expand Down
6 changes: 2 additions & 4 deletions src/main/kotlin/lotto/view/LottoOutputView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@ class LottoOutputView {
}
}

println("총 수익률은 ${lottoRoundStatistics.totalPrize.value / payment}입니다.")
println("총 수익률은 0.${(lottoRoundStatistics.totalPrize.value * 100 / payment)}입니다.")
}

companion object {
private const val WINNING_C0MMENT = """당첨 통계
|---------
"""
private const val WINNING_C0MMENT = "당첨 통계\n---------"
}
}
21 changes: 21 additions & 0 deletions src/main/kotlin/main.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import lotto.domain.LottoServiceRound
import lotto.domain.Money.Companion.toMoney
import lotto.view.LottoInputView
import lotto.view.LottoOutputView

fun main() = lotto()

fun lotto() {
val lottoServiceRound = LottoServiceRound()
val lottoInputView = LottoInputView()
val lottoOutputView = LottoOutputView()

val payment = lottoInputView.inputLottoBuy()
lottoServiceRound.buyLottos(payment.toLong().toMoney()).also {
lottoOutputView.currentLottos(it)
}

val winningLottoNumbers = lottoInputView.inputWinningLotto()
val lottoRoundStatistics = lottoServiceRound.lotteryDraw(winningLottoNumbers)
lottoOutputView.result(lottoServiceRound.allPayment().value, lottoRoundStatistics)
}

0 comments on commit 2dc324a

Please sign in to comment.