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

Conversation

Aimbe
Copy link

@Aimbe Aimbe commented Dec 20, 2024

μ•ˆλ…•ν•˜μ„Έμš” κ²½λ‘λ‹˜!λ§ˆμ§€λ§‰ 4단계 μ œμΆœν•©λ‹ˆλ‹€!
항상 ν”Όλ“œλ°± κ°μ‚¬ν•©λ‹ˆλ‹€!πŸ™‡β€β™‚οΈ

Copy link

@Rok93 Rok93 left a 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)
Copy link

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)
Copy link

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μ—μ„œ λ³€ν™˜ν•΄μ£Όλ„λ‘ ν•΄μ£Όλ©΄ 쒋을 것 κ°™μŠ΅λ‹ˆλ‹€.

Copy link

Choose a reason for hiding this comment

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

μΆ”κ°€μ μœΌλ‘œ 이 μˆ˜λ™(으둜 μž…λ ₯ 받은) 둜또λ₯Ό μƒμ„±ν•΄μ£ΌλŠ” 역할은 μ–΄λ–€ κ°μ²΄μ—κ²Œ μœ„μž„ν• μ§€λ„ κ³ λ―Όν•΄λ³΄μ‹œλ©΄ 쒋을 것 κ°™μ•„μš”. πŸ˜ƒ


import Lottos

class LottoPurchaseManager {
Copy link

Choose a reason for hiding this comment

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

LottoPurchaseManager의 경우 λ³„λ„μ˜ μƒνƒœ 값을 가지지 μ•ŠλŠ”λ°, object class둜 선언해도 λ˜μ§€ μ•Šμ„κΉŒμš”? πŸ€”

Comment on lines +27 to +29
operator fun plus(lotto: Lottos): List<Lotto> {
return tickets + lotto.tickets
}
Copy link

Choose a reason for hiding this comment

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

μ•„λž˜μ™€ 같이 리턴 νƒ€μž…μ„ Lottos둜 변경해보면 μ–΄λ–¨κΉŒμš”? πŸ˜ƒ

Suggested change
operator fun plus(lotto: Lottos): List<Lotto> {
return tickets + lotto.tickets
}
operator fun plus(lotto: Lottos): Lottos {
return Lottos(tickets + lotto.tickets)
}

Comment on lines +42 to +50
val manualLottos =
(1..count).map {
val numbers =
readln().split(",")
.map { it.trim().toInt() }
.map { LottoNumber(it) }
Lotto(numbers)
}
return Lottos.from(manualLottos)
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에 μœ„μΉ˜μ‹œν‚€λ©΄ 쒋을 것 κ°™μŠ΅λ‹ˆλ‹€. πŸ˜‰

Comment on lines +37 to +46
@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)
}
Copy link

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))
Copy link

Choose a reason for hiding this comment

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

createLottoNumbers κ°€ μ•„λ‹ˆλΌ μ²˜μŒλΆ€ν„° createLotto λ©”μ„œλ“œλ₯Ό λ§Œλ“€λ©΄ 일일이 Lotto둜 λž©ν•‘ν•˜λŠ” λ‘œμ§λ“€μ„ 쀄일 수 μžˆμ„ 것 κ°™μ•„μš”. πŸ˜ƒ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants