-
Notifications
You must be signed in to change notification settings - Fork 230
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
[코드 리뷰용 PR입니다!] - 재구현 스터디 #247
base: main
Are you sure you want to change the base?
Conversation
strike == 0 && ball == 0 -> "낫싱" | ||
strike > 0 && ball == 0 -> "${strike}스트라이크" | ||
strike == 0 && ball > 0 -> "${ball}볼" | ||
else -> "${ball}볼 ${strike}스트라이크" |
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.
볼, 스트라이크, 낫싱 문자열로 Constants 클래스로 관리하면 좋을 것 같아요!
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.
앗,, 이 부분을 놓쳤네요ㅠㅠ 감사합니다
do { | ||
oneCycleGame() | ||
} while (baseBall.gameStatus()) |
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.
do-while문을 사용하니까 코드가 엄청 간경하네요,,, 저도 배워갑니다!!
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 makeIntList(number: String): List<Int> { | ||
return number.map { it.digitToInt() }.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.
map의 반환값이 List라 굳이 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.
수정하겠습니다!!
gameInit() | ||
gameStart() | ||
gameEnd() |
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 baseball.util.Constants.RESTART | ||
import java.lang.IllegalArgumentException | ||
|
||
object Validator { |
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.
전체적으로 require()
문을 사용하는 것이 더 좋아보여요!
class BaseBall { | ||
private var _strike = 0 | ||
val strike: Int | ||
get() = _strike | ||
|
||
private var _ball = 0 | ||
val ball: Int | ||
get() = _ball | ||
|
||
|
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.
get()에 대해서는 활용법을 잘 몰랐는데 정말 적확한 곳에 사용하신 것 같아요. 잘 배워갑니다
object Constants { | ||
const val RESTART = "1" | ||
const val QUIT = "2" | ||
const val GAME_NUMBER_LENGTH = 3 | ||
const val START_INDEX = 1 | ||
const val END_INDEX = 9 | ||
const val REGEX = "[1-9]{3}" | ||
} |
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.
저도 object를 사용하였는데, 클래스와 같은 곳에 배치하니 가독성이 떨어져서 고민이 많았습니다. 근데 다른 패키지로 빼서 표현할 수도 있다는 것은 아는게 적어서 전혀 생각도 못한 방법이었는데...와 정말 좋은 아이디어 인 것 같아요
No description provided.