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

[로또] 정남진 미션 제출합니다. #176

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

ErroredPasta
Copy link

No description provided.

README에 프로젝트 개요, 기능, 사용 방법 작성
- 갯수가 주어질 경우 해당 갯수만큼 로또를 생성하는지
- 로또의 번호가 오름차순이 되도록 생성되는지
Comment on lines +46 to +48
const val MISMATCH_NUMBER_OF_LOTTO_NUMBERS_MESSAGE = "${NUMBER_OF_LOTTO_NUMBERS}개의 숫자가 필요합니다."
const val DUPLICATED_NUMBER_EXIST_MESSAGE = "중복된 숫자가 존재합니다."
const val NUMBERS_NOT_IN_VALID_RANGE = "모든 숫자는 반드시 $MIN_NUMBER~$MAX_NUMBER 사이에 존재해야 합니다."
Copy link

Choose a reason for hiding this comment

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

상수들을 정말 잘 사용하신 거 같아요. 최소 값이나 최대 값들이 바뀐다면 유지 보수하기도 편해보이네요!

Comment on lines +28 to +34
runCatching {
view.getMoney()
}.onSuccess {
_money = it
}.onFailureOtherThanNoSuchElementException { error ->
view.displayErrorMessage(message = error.message)
getMoney()
Copy link

Choose a reason for hiding this comment

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

아 이런 방법도 있네요. 이런 코드들을 발견할 때마다 리뷰를 하길 잘했다는 생각이 들어요! 배움 주셔서 감사합니다!

Comment on lines +68 to +97
private fun Result.convertToString(): String = buildString {
append(matchingNumberCount)
append(MATCHING_NUMBERS_SUFFIX_MESSAGE)
if (this@convertToString == Result.SECOND_PLACE) append(BONUS_NUMBER_MATCH_MESSAGE)
append(' ')
append('(')
append(PRIZE_FORMAT.format(prize))
append(KRW)
append(')')
}

override fun onGetResultsDone() {
presenter.getProfit()
}

private fun readInt(): Int = runCatching {
Console.readLine().toInt()
}.onFailure { error ->
if (error is NumberFormatException) throw NumberFormatException(INPUT_NOT_NUMBER)
}.getOrThrow()

companion object {
const val ERROR_MESSAGE_PREFIX = "[ERROR]"
const val DEFAULT_ERROR_MESSAGE = "에러가 발생했습니다. 다시 시도해주세요."
const val NUMBER_DELIMITER = ','
const val INPUT_NOT_NUMBER = "숫자를 입력해 주세요."
const val MATCHING_NUMBERS_SUFFIX_MESSAGE = "개 일치"
const val BONUS_NUMBER_MATCH_MESSAGE = ", 보너스 볼 일치"
const val PRIZE_FORMAT = "%,d"
const val KRW = "원"
Copy link

Choose a reason for hiding this comment

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

이런 코드들에서 남진님이 분리하는 것에 엄청 신경쓰신 의도를 엿볼 수 있는 거 같아요. 정말 깔끔한 것 같습니다!

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