-
Notifications
You must be signed in to change notification settings - Fork 119
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
[자동차 경주] 천지윤 미션 제출합니다. #100
base: main
Are you sure you want to change the base?
Conversation
if (!(cars.all { it -> it.count() <= 5 })) { | ||
throw IllegalArgumentException("자동차 이름은 5자 이하만 가능합니다") | ||
} |
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.
람다식에서 사용되는 기본 변수 네임을 it 그대로 사용하실 거라면
it ->
은 생략해도 될 것 같네요 !
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.
오 생략해도 되는지 몰랐네요. 알려주셔서 감사합니다!
|
||
import java.lang.NumberFormatException | ||
|
||
class Validation { |
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.
저는 아래 케이스에 대해서도 고민을 해봤는데요 한번 생각해보셔도 좋을거 같습니다 !
게임 플레이를 한명만 입력되도 허용할 것인지?
이름에 특수문자를 허용하실 것인지?
,가 아닌 구분자가 들어왔을 때 : 3;4;5
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.
감사합니다. 오류는 아니라고 생각해서 하지 않았는데, 사용자가 실수하는 것도 고려해볼 수가 있겠네요!
|
||
return count | ||
} | ||
|
||
fun main() { |
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.
그렇군요! 몰랐었는데 감사합니다!
} | ||
|
||
fun isCanGo(): Boolean { | ||
return Randoms.pickNumberInRange(0, 9) >= 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.
0과 9, 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.
아하 좋네요! 앞으로 의미가 있는 숫자는 상수화를 해야겠습니다
fun winnerPrint(winners: List<String>) { | ||
println("최종 우승자 : ${winners.joinToString(", ")}") | ||
|
||
} |
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.
코틀린 함수 네이밍 컨벤션에 따르면 동사 + 명사 구조로 네이밍을 하도록 가이드하고 있습니다 !
println
처럼 printWinner
로 네이밍 하는 것이 맞을 것 같습니다 🤔
fun gameResult(carName: String, movingCount: Int) { | ||
println("$carName : ${"-".repeat(movingCount)}") | ||
} |
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.
함수의 이름이 "게임의 결과"를 출력한다는 의미일까요 ? 그렇다면 printGameResult
는 어떨까요 !
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.
유효성 검사, 입출력 View를 나누신 것 처럼 게임을 진행하는 로직도 분리하면 좋을 것 같습니다 !
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주차도 수고하셨습니다!
요구사항 지킬려고 readme에 'depth 2이하'라고 기록해두는 습관 좋을 거같습니다.
저도 배우고 갑니다! 저희 3주차도 화이팅해요!!
} | ||
|
||
fun inputCount() { | ||
println("시도할 횟수는 몇 회인가요?") |
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.
오 문자열로 한 번 더 빼는 거군요. 감사합니다
} | ||
|
||
fun checkInputCarIsNotEmpty(inputCar: String) { | ||
if (inputCar == "") { |
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.
와 감사합니다. 코틀린 문법 하나 또 배웠습니다!!
@@ -3,6 +3,25 @@ package racingcar | |||
import camp.nextstep.edu.missionutils.Randoms | |||
import camp.nextstep.edu.missionutils.Console | |||
|
|||
|
|||
fun getWinnerIndex(carsMovings : Array<Int>): MutableList<Int> { |
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.
저희 1주차 안드로이드 피드백에 배열 대신 컬렉션을 사용한다!고 있습니다. 다음에는 List를 사용해서 구현해보는 건 어떨까요?
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.
아 맞네요 잊어버렸던 피드백인데 알려주셔서 감사합니다! ㅠㅠㅠ
구현할 기능 목록
자동차 이름 분류
이동할 횟수
랜덤 이동값
최종 우승자
depth 2이하
테스트