Open
Conversation
- 기존 RacingGame에서 다루던 결과 출력을 RacingController에서 다루도록 분리 - 결과 출력: 중간 출력과 우승자 출력
CommitTheKermit
left a comment
There was a problem hiding this comment.
코드 잘 읽었습니다. 전체적으로 MVC 패턴을 잘 준수하셔서 쉽게 읽혔네요. 코드를 읽다보니 저도 지적받은 사항이 있어서 저도 몇 글자 적어봤습니다. 다가오는 3주차도 화이팅입니다~
Comment on lines
+3
to
+16
| object CarValidator { | ||
| fun parse(input: String): List<String> { | ||
| val names = input.split(",").map { it.trim() } | ||
| validateCarName(names) | ||
|
|
||
| return names | ||
| } | ||
|
|
||
| private fun validateCarName(names: List<String>) { | ||
| require(names.all { it.isNotBlank() }) { throw IllegalArgumentException("자동차 이름은 비어 있을 수 없습니다.") } | ||
| require(names.all { it.length <= 5 }) { throw IllegalArgumentException("자동차 이름은 5자 이하만 가능합니다.") } | ||
| require(names.distinct().size == names.size) { throw IllegalArgumentException("자동차 이름은 중복될 수 없습니다.") } | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
CarValidator에 validate 말고도 parse도 있네요. parse를 따로 parser 클래스에 두시거나 Car 클래스에 두시는 것도 좋았을 것 같습니다.
Comment on lines
+8
to
+13
| fun readCarNames(): List<String> { | ||
| println("경주할 자동차 이름을 입력하세요.(이름은 쉼표(,) 기준으로 구분)") | ||
| val carsInput = Console.readLine() | ||
|
|
||
| return CarValidator.parse(carsInput) | ||
| } |
There was a problem hiding this comment.
저도 지적받은 사항인데, InputView에서는 parse와 같은 다른 처리를 두지 않고 입력만 처리하면 좋을 것 같습니다!
Comment on lines
+9
to
+10
| private val inputView: InputView = InputView(), | ||
| private val outputView: OutputView = OutputView() |
There was a problem hiding this comment.
InputView, OutputView는 프로젝트 내에서 여러 번 할당되지도 않고 상태도 갖고 있지 않기에 object 클래스로 선언하여 static 처럼 쓰시는 게 좋을 거 같습니다!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
기능 목록
1. 입력
2. 경주 준비
3. 경주 시작
4. 경주 결과
5. 출력
스스로 판단한 사항