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

[코드 리뷰용 PR입니다!] - 재구현 스터디 #247

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

Conversation

lh99j
Copy link

@lh99j lh99j commented Nov 3, 2023

No description provided.

Comment on lines +16 to +19
strike == 0 && ball == 0 -> "낫싱"
strike > 0 && ball == 0 -> "${strike}스트라이크"
strike == 0 && ball > 0 -> "${ball}볼"
else -> "${ball}볼 ${strike}스트라이크"

Choose a reason for hiding this comment

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

볼, 스트라이크, 낫싱 문자열로 Constants 클래스로 관리하면 좋을 것 같아요!

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 +25 to +27
do {
oneCycleGame()
} while (baseBall.gameStatus())

Choose a reason for hiding this comment

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

do-while문을 사용하니까 코드가 엄청 간경하네요,,, 저도 배워갑니다!!

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 makeIntList(number: String): List<Int> {
return number.map { it.digitToInt() }.toList()

Choose a reason for hiding this comment

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

map의 반환값이 List라 굳이 toList()를 할 필요는 없어 보입니다!

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 +14 to +16
gameInit()
gameStart()
gameEnd()

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 {

Choose a reason for hiding this comment

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

전체적으로 require() 문을 사용하는 것이 더 좋아보여요!

Comment on lines +5 to +14
class BaseBall {
private var _strike = 0
val strike: Int
get() = _strike

private var _ball = 0
val ball: Int
get() = _ball


Choose a reason for hiding this comment

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

get()에 대해서는 활용법을 잘 몰랐는데 정말 적확한 곳에 사용하신 것 같아요. 잘 배워갑니다

Comment on lines +3 to +10
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}"
}

Choose a reason for hiding this comment

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

저도 object를 사용하였는데, 클래스와 같은 곳에 배치하니 가독성이 떨어져서 고민이 많았습니다. 근데 다른 패키지로 빼서 표현할 수도 있다는 것은 아는게 적어서 전혀 생각도 못한 방법이었는데...와 정말 좋은 아이디어 인 것 같아요

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.

3 participants