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
base: eedys1234
Are you sure you want to change the base?
[Step4] 로또(수동) #564
Conversation
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>
Signed-off-by: AI2팀-이정환 <eedys@ex-em.com>
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.
정환님 안녕하세요!
step4
브랜치가 아닌, step3
에서 작업해주셨네요! 이 부분은 DM으로 말씀드렸습니다!
그리고 추가적으로 리뷰가 빠진 부분은 dm으로 드렸고, 린트와 테스트 추가 부탁드려요.
val numbers = splitManual.map { s -> s.toIntOrNull() ?: throw IllegalArgumentException() }.toList() | ||
return Lotto(numbers) | ||
} | ||
|
||
} | ||
} |
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.
린트 확인해주세요~
|
||
fun create(num: String): Lotto { | ||
val splitManual = num.split(", ") | ||
val numbers = splitManual.map { s -> s.toIntOrNull() ?: throw IllegalArgumentException() }.toList() |
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.
val numbers = splitManual.map { s -> s.toInt()}
으로도 충반하답니다. 더 명확한 NumberFormatException
가 발생하기 때문입니다.
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.
그 말씀이시군요! 넵 감사합니다!
@@ -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> { |
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.
private
좋네요! 하지만 위에 있는 자동로또도 private
으로 해야 할것 같아요!
그리고 issue
가 2개가 생겼으니, 함수의 네이밍을 조금 더 특별히 줘도 괜찮을것 같네요!
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.
넵!
val lottos = mutableListOf<Lotto>() | ||
|
||
for(manual in manuals) { |
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.
list
를 만들고 add
를 하는게 아닌, 컬렉션에서 제공하는 함수를 사용해보는건 어떨까요?
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.
넵!
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() | ||
} |
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.
해당 메서드를 외부에서 계속 호출해서 완전한 형태로 만드는것 보단, WinningMachine
에서 반복하면서 List
를 만든 후 Statistics
에 전달하여 Statistics
가 스스로 만들게 하는건 어떨까요?
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.
이해가 잘되지 않네요ㅠㅠㅠ
} | ||
|
||
private fun toOneIfContainsInLotto(num: LottoNum): Int { | ||
return if(lotto.contains(num)) 1 else 0 | ||
} | ||
|
||
private fun containsBonusNum(lotto: Lotto): Boolean { |
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.
해당 메서드를 correspondLottoResult
밑에 배치하는건 어떨가요? 코드는 위에서 아래로 읽기 떄문입니다.
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.
말씀하신대로 코드를 위에서 아래로 읽는다면,
correspondLottoResult
containsLottoCount
containsBonusNum
toOneIfContainsInLotto
순으로 메서드를 정렬해도 괜찮을까요??
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.
넵 맞습니다
getter를 최대한 사용하지 않으려해도 View 에서는 꺼내야하는 것 같은데 이게 맞을까요?? |
No description provided.