-
Notifications
You must be signed in to change notification settings - Fork 108
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
[자동차 경주] 조형석 미션 제출합니다. #98
base: main
Are you sure you want to change the base?
Conversation
racing -> car 클래스 자동차가 랜덤으로 전진하는 것은 자동차 역할이므로 수정
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.
2주차 과제도 고생하셨어요!!
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.
메시지 파일은 Class보단 Object 파일로 관리하는 게 더 효율적일 거 같아요! Object는 정의하는 동시에 객체를 생성해서, 하나의 객체를 재사용할 수 있다네요!
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.
좋은 공부 주제네요 공부해서 적용하겠습니다. 좋은 의견 감사합니다!
class Random { | ||
fun randomGenerator(): Boolean { | ||
val randomNum = Randoms.pickNumberInRange(0, 9) | ||
return randomNum >= 4 |
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.
이런 식으로 리턴할 수도 있군요!
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.
맞아요 저도 이번에 알았어요!!
@Test | ||
fun `go 호출 시 randomGenerator가 true를 반환하면 status가 증가한다`() { | ||
camp.nextstep.edu.missionutils.test.Assertions.assertRandomNumberInRangeTest( | ||
{ |
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.
camp.nextstep.edu.missionutils.test.Assertions API를 import문에 작성하지 않고 따로 빼신 이유가 있으실까요?
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.
의도된 것이 아니였어요 저도 미처 확인하지 못했네요!
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.
2주차 고생하셨습니다.
아키텍처를 깔끔하게 잘 짠 것 같아요!
짧게나마 리뷰 남기고 갑니다~
#78
class RacingController { | ||
fun playGame() { | ||
val carName = Input().getCars() | ||
val tryCount = Input().getCount() | ||
Racing().race(tryCount, Racing().readyToRace(carName)) |
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.
Input()
과 Racing()
을 통해서 객체를 계속 생성하는데 계속해서 다른 객체를 사용하는 것으로 보입니다.
객체를 생성하고 해당 객체를 여러번 사용하는 방법은 어떨까요?
class RacingController { | |
fun playGame() { | |
val carName = Input().getCars() | |
val tryCount = Input().getCount() | |
Racing().race(tryCount, Racing().readyToRace(carName)) | |
class RacingController { | |
private val input = Input() | |
private val racing= Racing() | |
fun playGame() { | |
val carName = input.getCars() | |
val tryCount = input.getCount() | |
val cars = racing.readyToRace(carName) | |
racing.race(tryCount, cars) |
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.
그렇네요!! 재사용하고 있지 않았다니 충격입니다..
좋은 리뷰 감사합니다.
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.
덕분에 코드 분리, 테스트 방법 들을 잘 배워갑니다 !
MOVING_FORWARD, STOP, MOVING_FORWARD, | ||
MOVING_FORWARD, STOP, MOVING_FORWARD, | ||
MOVING_FORWARD, STOP, MOVING_FORWARD |
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.
기능 테스트를 어떻게 작성하는지 작성하신 코드를 보고 이해할 수 있었습니다.
내부적으로 테스트방식을 어떻게 사용하는지 덕분에 잘 배워갑니다 !
winner.append(Constants().WINNER) | ||
winner.append(winners.keys.joinToString("${Constants().COMMA} ")) |
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 로 한다면 불필요한 객체 생성을 막을 수 있을 것 같습니다 !
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에 대해 공부하고 적용하도록 할게요! 감사합니다
class Input { | ||
fun getCars(): List<String> { | ||
println(Constants().INSERT_CAR_NAMES) | ||
val carName = Console.readLine().split(Constants().COMMA) |
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().COMMA 보다 더 짧기도 하고, 좀 더 자명하지 않을까 싶습니다.. 개인적인 생각이에요!
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.
',' 이런 것들도 무조건 해줘야 하는 것으로 알고 있었는데 아닌가봐요..
val ERROR_NAME_LENGTH = "자동차 이름은 1~5자 길이입니다." | ||
val ERROR_NAME_DUPLICATION = "자동차 이름이 중복되었습니다." | ||
val ERROR_COUNT_IS_NUM = "시도 횟수는 숫자를 입력해야 합니다." | ||
val ERROR_CAR_MINIMUM = "자동차는 2대 이상 입력해야 합니다." |
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.
ERROR 메시지를 나타내는 Constants 와 , 다른 Constants 를 클래스 분리하면 어떨까요 ??
ErrorConstants, InputConstants 같이 하면 필요한 부분을 찾기 쉬울 것 같습니다 !
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.
좋은 생각이네요 감사합니다!
No description provided.