Skip to content

[자동차 경주] 고민석 미션 제출합니다.#53

Open
k-kms1064 wants to merge 8 commits into
woowacourse-precourse:mainfrom
kominsuk1064:k-kms1064
Open

[자동차 경주] 고민석 미션 제출합니다.#53
k-kms1064 wants to merge 8 commits into
woowacourse-precourse:mainfrom
kominsuk1064:k-kms1064

Conversation

@k-kms1064
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@eungyeong12 eungyeong12 left a comment

Choose a reason for hiding this comment

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

2주차 고생 많으셨습니다!
각 클래스의 역할과 코드의 흐름이 명확해서 이해하기가 수월했습니다!

Comment on lines +7 to +24
fun readCarNames(): List<String> {
println("경주할 자동차 이름을 입력하세요.(이름은 쉼표(,) 기준으로 구분)")
val input = Console.readLine().trim()
require(input.isNotBlank()) { "자동차 이름을 입력해야 합니다." }

val names = input.split(",").map { it.trim() }
require(names.all { it.length in 1..5 }) { "자동차 이름은 1자 이상, 5자 이하여야 합니다." }

return names
}

fun readTryCount(): Int {
println("시도할 횟수는 몇 회인가요?")
val input = Console.readLine().trim()
val number = input.toIntOrNull() ?: throw IllegalArgumentException("시도 횟수는 숫자여야 합니다.")
require(number > 0) { "시도 횟수는 1 이상이어야 합니다." }
return number
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

입력과 검증을 분리하면 더 좋은 설계가 되지 않을까 싶습니다!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

피드백 감사합니다!

입력은 InputView, 검증은 별도의 Validator 객체로 분리해서 테스트하기 쉽게 구조를 개선해보겠습니다.

Comment on lines +12 to +16
fun move(number: Int) {
if (number >= 4) {
position += 1
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

매직 넘버를 상수화하면 좋을 것 같습니다!

Copy link
Copy Markdown
Author

@k-kms1064 k-kms1064 Oct 29, 2025

Choose a reason for hiding this comment

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

피드백 감사합니다!

4를 하드코딩한 부분은 저도 마음에 걸렸는데, 수정하면서 Cars 클래스에도 반복되는 값이 있는지 같이 점검해보겠습니다.

Comment on lines +14 to +21
fun start(): List<Car> {
repeat(tryCount) {
val randomNumbers = generateRandomNumbers()
cars.moveAll(randomNumbers)
ResultView.printRoundResult(cars.getStatus())
}
return cars.getWinners()
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

도메인과 출력 로직이 결합되어 있어서 책임을 분리하면 좋을 것 같습니다!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

RacingGame이 게임 진행과 출력까지 담당하고 있어서 말씀하신 부분이 맞는 것 같습니다.

ResultView로 완전히 분리해서 도메인은 순수하게 게임 로직만 담당하도록 리팩터링하겠습니다!

Copy link
Copy Markdown

@joon0447 joon0447 left a comment

Choose a reason for hiding this comment

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

안녕하세요! 2주차 고생 많으셨습니다.
함수명의 통일성과 가독성이 되게 좋은 것 같네요!!

Comment on lines +8 to +9
require(name.isNotBlank()) { "자동차 이름은 비어 있을 수 없습니다." }
require(name.length <= 5) { "자동차 이름은 5자 이하여야 합니다." }
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

출력 메시지의 상수화도 한번 고민해보시면 좋을 것 같습니다!

Copy link
Copy Markdown
Author

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.

4 participants