Conversation
Flamme1004K
left a comment
There was a problem hiding this comment.
안녕하세요!
전체적으로 구현 잘해주셨네요 💯
몇가지 코멘트를 남겼으니 확인 부탁드리겠습니다!
궁금하신 점에 대해서는 DM 부탁드립니다!!
확인 후 다시 리뷰 요청 부탁드립니다!
| fun startGame() { | ||
| val inputValue = InputView.executeInputScreen() | ||
| CarService().execute(inputValue.tryCount, inputValue.carNumber) | ||
| val raceCars = CarService(getCarMoveRandomValue()).execute(inputValue.carNames) |
| @@ -0,0 +1,40 @@ | |||
| 경주할 자동차 이름을 추출 하는 기능. | |||
There was a problem hiding this comment.
description.md 파일의 위치는 src가 아닌 다른 디렉터리에 있어야하지 않을까요?
| fun getMoveCount(): Int { | ||
| return moveCount | ||
| } | ||
|
|
||
| fun getCarName(): String { | ||
| return name | ||
| } |
There was a problem hiding this comment.
코틀린의 프로퍼티는 접근자를 모두 지원하고 있어요. name에 대한 접근 제어자를 public으로 변경하면 되죠.
하지만 moveCount인 경우에는 set도 같이 쓸 수가 있기 때문에 다른 처리가 필요할거에요. 이 부분에 대해서는 한번 찾아보시겠어요~?
| import src.racingcar.parseComma | ||
|
|
||
| class CarService( | ||
| private val carMoveRandomValue: Int |
There was a problem hiding this comment.
CarService는 자동차에 움직임에 대해서 랜덤인지 아닌지 알 수 없다고 생각합니다. carMobeRandomValue 보다는 자동차의 움직임에 대한 carMoveValue가 좋지 않을까요? 🤔
| private val carMoveRandomValue: Int | ||
| ) { | ||
|
|
||
| fun execute(carNames: String): MutableList<Car> { |
There was a problem hiding this comment.
MutableList는 가변리스트에요. 가변 리스트인 경우에는 어떤 단점이 있을까요?
| class Race( | ||
| private var cars: MutableList<Car> = mutableListOf() | ||
| ) { | ||
|
|
||
| fun create(carNames: List<String>): Race { | ||
| for (carName in carNames) { | ||
| cars.add(Car(carName)) | ||
| } | ||
|
|
||
| return this | ||
| } |
There was a problem hiding this comment.
| private val racingCars: List<Car> | ||
| ) { | ||
| fun findWinners(): List<Car> { | ||
| return racingCars.filter { car -> car.getMoveCount() >= racingCars.maxOf { it.getMoveCount() } } |
There was a problem hiding this comment.
| return racingCars.filter { car -> car.getMoveCount() >= racingCars.maxOf { it.getMoveCount() } } | |
| val max = racingCars.maxOf { it.getMoveCount() } | |
| return racingCars.filter { car -> car.getMoveCount() >= max } |
maxOf 사용 좋습니다 👍
변경 전과 변경 후의 코드의 차이는 무엇일까요?
| @@ -0,0 +1,5 @@ | |||
| package src.racingcar | |||
| import org.junit.jupiter.api.Test | ||
| import src.racingcar.domain.CarService | ||
|
|
||
| class CarServiceTest { |
Flamme1004K
left a comment
There was a problem hiding this comment.
안녕하세요!
피드백 반영 감사합니다 💯
몇가지 코멘트를 남겼으니 확인 부탁드리겠습니다!
궁금하신 점에 대해서는 DM 부탁드립니다!!
확인 후 다시 리뷰 요청 부탁드립니다!
| @@ -0,0 +1,22 @@ | |||
| package src.racingcar.domain | |||
|
|
|||
| open class Car( | |||
| var moveCount: Int = moveCount | ||
| protected set |
There was a problem hiding this comment.
| var moveCount: Int = moveCount | |
| protected set | |
| var moveCount: Int = moveCount | |
| private set |
kotlin에서 protected와 private의 차이는 무엇일까요~?
| open fun move(carMoveNumber: Int = (MOVE_START_POINT..MOVE_END_POINT).random()): Int { | ||
| if (CAR_MOVE_CONDITION_NUMBER <= carMoveNumber) moveCount++ | ||
|
|
||
| return moveCount | ||
| } |
| fun start(): List<Car> { | ||
| cars.forEach { it.move() } | ||
|
|
||
| return cars | ||
| } |
There was a problem hiding this comment.
도메인 클래스에 대한 테스트는 모두 해야한다고 생각해요! race에 결과에 대한 테스트는 어떻게 해야 할까요?
참고 문서 입니다!
| ) { | ||
| fun findWinners(): List<Car> { | ||
| val max = racingCars.maxOf { it.moveCount } | ||
| return racingCars.filter { car -> car.moveCount >= max } |
There was a problem hiding this comment.
| return racingCars.filter { car -> car.moveCount >= max } | |
| return racingCars.filter { car -> car.moveCount == max } |
== 비교로도 충분하지 않을까요?

제출이 늦었습니다.. 열심히 해보겠습니다!!