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

[Step4] 로또(수동) #564

Open
wants to merge 36 commits into
base: eedys1234
Choose a base branch
from
Open

Conversation

eedys1234
Copy link

No description provided.

eedys and others added 30 commits November 26, 2022 01:43
Signed-off-by: AI2팀-이정환 <eedys@ex-em.com>
# Conflicts:
#	src/main/kotlin/lotto/domain/Lotto.kt
#	src/main/kotlin/lotto/domain/LottoMachine.kt
#	src/main/kotlin/lotto/domain/LottoNum.kt
#	src/test/kotlin/lotto/LottoTest.kt
Signed-off-by: AI2팀-이정환 <eedys@ex-em.com>
Signed-off-by: AI2팀-이정환 <eedys@ex-em.com>
Copy link

@ohgillwhan ohgillwhan left a comment

Choose a reason for hiding this comment

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

정환님 안녕하세요!
step4 브랜치가 아닌, step3에서 작업해주셨네요! 이 부분은 DM으로 말씀드렸습니다!
그리고 추가적으로 리뷰가 빠진 부분은 dm으로 드렸고, 린트와 테스트 추가 부탁드려요.

val numbers = splitManual.map { s -> s.toIntOrNull() ?: throw IllegalArgumentException() }.toList()
return Lotto(numbers)
}

}
}

Choose a reason for hiding this comment

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

린트 확인해주세요~


fun create(num: String): Lotto {
val splitManual = num.split(", ")
val numbers = splitManual.map { s -> s.toIntOrNull() ?: throw IllegalArgumentException() }.toList()

Choose a reason for hiding this comment

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

val numbers = splitManual.map { s -> s.toInt()}
으로도 충반하답니다. 더 명확한 NumberFormatException가 발생하기 때문입니다.

Copy link
Author

Choose a reason for hiding this comment

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

그 말씀이시군요! 넵 감사합니다!

@@ -19,7 +19,7 @@ class LottoMachine(private val generator: Generator) {
.toList()
}

fun issue(manuals: List<String>): List<Lotto> {
private fun issue(manuals: List<String>): List<Lotto> {

Choose a reason for hiding this comment

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

private 좋네요! 하지만 위에 있는 자동로또도 private으로 해야 할것 같아요!
그리고 issue가 2개가 생겼으니, 함수의 네이밍을 조금 더 특별히 줘도 괜찮을것 같네요!

Copy link
Author

Choose a reason for hiding this comment

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

넵!

Comment on lines 23 to 25
val lottos = mutableListOf<Lotto>()

for(manual in manuals) {

Choose a reason for hiding this comment

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

list를 만들고 add를 하는게 아닌, 컬렉션에서 제공하는 함수를 사용해보는건 어떨까요?

Copy link
Author

Choose a reason for hiding this comment

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

넵!

Comment on lines 5 to 15
private val value: MutableMap<Rank, MutableList<Lotto>> = mutableMapOf()

fun add(rank: Rank, lotto: Lotto) {
value[rank]?.add(lotto) ?: init(rank).add(lotto)
val list = value[rank] ?: init(rank)
list.add(lotto)
}

fun from(rank: Rank): List<Lotto> {
return value[rank]?.toList() ?: init(rank).toList()
val result = value[rank] ?: init(rank)
return result.toList()
}

Choose a reason for hiding this comment

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

해당 메서드를 외부에서 계속 호출해서 완전한 형태로 만드는것 보단, WinningMachine에서 반복하면서 List를 만든 후 Statistics에 전달하여 Statistics가 스스로 만들게 하는건 어떨까요?

Copy link
Author

Choose a reason for hiding this comment

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

이해가 잘되지 않네요ㅠㅠㅠ

}

private fun toOneIfContainsInLotto(num: LottoNum): Int {
return if(lotto.contains(num)) 1 else 0
}

private fun containsBonusNum(lotto: Lotto): Boolean {

Choose a reason for hiding this comment

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

해당 메서드를 correspondLottoResult 밑에 배치하는건 어떨가요? 코드는 위에서 아래로 읽기 떄문입니다.

Copy link
Author

@eedys1234 eedys1234 Dec 21, 2022

Choose a reason for hiding this comment

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

말씀하신대로 코드를 위에서 아래로 읽는다면,

correspondLottoResult
containsLottoCount
containsBonusNum
toOneIfContainsInLotto

순으로 메서드를 정렬해도 괜찮을까요??

Choose a reason for hiding this comment

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

넵 맞습니다

@eedys1234
Copy link
Author

getter를 최대한 사용하지 않으려해도 View 에서는 꺼내야하는 것 같은데 이게 맞을까요??

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.

None yet

3 participants