-
Notifications
You must be signed in to change notification settings - Fork 357
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
base: aimbe
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ νΈλ 4λ¨κ³ λ―Έμ
μ ꡬνν΄μ£Όμ
¨μ΅λλ€. π
μ΄μ λ‘λ λ―Έμ
μ’
λ£λ μΌλ§ λ¨μ§ μμκ΅°μ ππ
μ‘°κΈ λ μ§κ³ λμ΄κ°λ©΄ μ’μ λΆλΆλ€μ΄ 보μ¬μ μ½λ©νΈ λ¨κ²¨λμμ΅λλ€!
νμΈν΄μ λ°μ λΆνλ릴κ²μ. π
μ΄μ μ λ§ κ±°μ λλκ°λ λ§μ§λ§κΉμ§ νμ΄ν
μ
λλ€. πͺπͺπͺ
val manualCount = InputView().readManualLottoCount() | ||
val manualLottos = InputView().readManualLottoNumbers(manualCount) | ||
|
||
val lottos = LottoService(LottoPurchaseManager()).purchase(purchaseAmount, manualLottos) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
νμ¬ LottoService κ°μ²΄λ₯Ό λλ² μμ±ν΄μ μ¬μ©νκ³ μλλ°μ.
LottoService
κ°μ²΄λ νλ² μμ±ν λ€μ μ¬μ¬μ©νλ©΄ μ΄λ¨κΉμ?
val purchaseAmount = LottoPrice(InputView().readPurchaseAmount()) | ||
|
||
val manualCount = InputView().readManualLottoCount() | ||
val manualLottos = InputView().readManualLottoNumbers(manualCount) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Viewκ° Modelμ μμ‘΄νκ³ μλ κ² κ°μμ. π€
View λ¨μμλ μ
λ ₯ κ°μΌλ‘ List<List<Int>>
μ κ²°κ³Όλ₯Ό κ°μ Έμ€κ³ , μ΄ κ²°κ³Όλ Controllerμμ λ³νν΄μ£Όλλ‘ ν΄μ£Όλ©΄ μ’μ κ² κ°μ΅λλ€.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μΆκ°μ μΌλ‘ μ΄ μλ(μΌλ‘ μ λ ₯ λ°μ) λ‘λλ₯Ό μμ±ν΄μ£Όλ μν μ μ΄λ€ κ°μ²΄μκ² μμν μ§λ κ³ λ―Όν΄λ³΄μλ©΄ μ’μ κ² κ°μμ. π
|
||
import Lottos | ||
|
||
class LottoPurchaseManager { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LottoPurchaseManager
μ κ²½μ° λ³λμ μν κ°μ κ°μ§μ§ μλλ°, object classλ‘ μ μΈν΄λ λμ§ μμκΉμ? π€
operator fun plus(lotto: Lottos): List<Lotto> { | ||
return tickets + lotto.tickets | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μλμ κ°μ΄ λ¦¬ν΄ νμ μ Lottosλ‘ λ³κ²½ν΄λ³΄λ©΄ μ΄λ¨κΉμ? π
operator fun plus(lotto: Lottos): List<Lotto> { | |
return tickets + lotto.tickets | |
} | |
operator fun plus(lotto: Lottos): Lottos { | |
return Lottos(tickets + lotto.tickets) | |
} |
val manualLottos = | ||
(1..count).map { | ||
val numbers = | ||
readln().split(",") | ||
.map { it.trim().toInt() } | ||
.map { LottoNumber(it) } | ||
Lotto(numbers) | ||
} | ||
return Lottos.from(manualLottos) |
There was a problem hiding this comment.
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μ μμΉμν€λ©΄ μ’μ κ² κ°μ΅λλ€. π
@Test | ||
fun `2κ° μ΄ν λ§μΆλ©΄ λ―ΈλΉμ²¨μ΄λ€`() { | ||
val rank2 = Rank.from(matchCount = 2, matchBonus = false) | ||
val rank1 = Rank.from(matchCount = 1, matchBonus = false) | ||
val rank0 = Rank.from(matchCount = 0, matchBonus = false) | ||
|
||
assertThat(rank2).isEqualTo(Rank.NONE) | ||
assertThat(rank1).isEqualTo(Rank.NONE) | ||
assertThat(rank0).isEqualTo(Rank.NONE) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
νλμ ν μ€νΈ μΌμ΄μ€μ§λ§ λ€μν μΈμμ λν ν μ€νΈλ Parameterized Testλ₯Ό νμ©ν΄μ μ‘°κΈ λ κΉλνκ² λ³κ²½ν΄λ³Ό μ μμ κ² κ°μμ. π
val purchasedLottos = LottoService().purchase(lottoPrice) | ||
val manualLottos = | ||
List(manualCount) { | ||
Lotto(createLottoNumbers(1, 2, 3, 4, 5, 6)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createLottoNumbers
κ° μλλΌ μ²μλΆν° createLotto
λ©μλλ₯Ό λ§λ€λ©΄ μΌμΌμ΄ Lottoλ‘ λ©ννλ λ‘μ§λ€μ μ€μΌ μ μμ κ² κ°μμ. π
μλ νμΈμ κ²½λ‘λ!λ§μ§λ§ 4λ¨κ³ μ μΆν©λλ€!
νμ νΌλλ°± κ°μ¬ν©λλ€!πββοΈ