Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking β€œSign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸš€ 4단계 - 둜또(μˆ˜λ™) #1137

Open
wants to merge 13 commits into
base: aimbe
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: μˆ˜λ™ ꡬ맀 둜또 Lottos μ»¬λ ‰μ…˜ λ°˜ν™˜ν•˜λ„λ‘ λ³€κ²½
Aimbe committed Dec 20, 2024
commit 11fced24f346ab1a8e988272e2e328a12a36e5ed
4 changes: 4 additions & 0 deletions src/main/kotlin/lotto/domain/Lottos.kt
Original file line number Diff line number Diff line change
@@ -23,4 +23,8 @@ class Lottos(private val tickets: List<Lotto>) {
it
}.eachCount()
}

companion object {
fun from(lottos: List<Lotto>): Lottos = Lottos(lottos)
}
}
20 changes: 12 additions & 8 deletions src/main/kotlin/lotto/view/InputView.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package lotto.view

import Lottos
import lotto.domain.Lotto
import lotto.domain.LottoNumber

@@ -35,14 +36,17 @@ class InputView {
return readln().toInt()
}

fun readManualLottoNumbers(count: Int): List<Lotto> {
fun readManualLottoNumbers(count: Int): Lottos {
println("\nμˆ˜λ™μœΌλ‘œ ꡬ맀할 번호λ₯Ό μž…λ ₯ν•΄ μ£Όμ„Έμš”.")
return (1..count).map {
val numbers =
readln().split(",")
.map { it.trim().toInt() }
.map { LottoNumber(it) }
Lotto(numbers)
}

val manualLottos =
(1..count).map {
val numbers =
readln().split(",")
.map { it.trim().toInt() }
.map { LottoNumber(it) }
Lotto(numbers)
}
return Lottos.from(manualLottos)
Comment on lines +42 to +50
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(이미 μœ„μ—μ„œ μ–ΈκΈ‰ν–ˆμ—ˆμ§€λ§Œ) μ‹€μ œλ‘œ μž…λ ₯ 받은 값을 Domain Model인 Lotto 그리고 Lottos둜 λ³€κ²½ν•˜λŠ” λ‘œμ§μ€ Controller에 μœ„μΉ˜μ‹œν‚€λ©΄ 쒋을 것 κ°™μŠ΅λ‹ˆλ‹€. πŸ˜‰

}
}