-
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?
Changes from 1 commit
b05cab0
ac017e5
c8a6055
48f0460
0f70d83
55f7b91
509e05a
bfbf74d
0bc88c8
9625336
94aa1e6
8864304
87b64df
6f76779
b65741c
d9d0f1e
daf715a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package racingcar.Validation | ||
|
||
import java.lang.NumberFormatException | ||
|
||
class Validation { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. 감사합니다. 오류는 아니라고 생각해서 하지 않았는데, 사용자가 실수하는 것도 고려해볼 수가 있겠네요! |
||
fun checkCarNameLength(cars: List<String>) { | ||
if (!(cars.all { it -> it.count() <= 5 })) { | ||
throw IllegalArgumentException("자동차 이름은 5자 이하만 가능합니다") | ||
} | ||
Comment on lines
+7
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 람다식에서 사용되는 기본 변수 네임을 it 그대로 사용하실 거라면 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. 와 감사합니다. 코틀린 문법 하나 또 배웠습니다!! |
||
throw IllegalArgumentException("자동차 이름을 입력하지 않았습니다") | ||
} | ||
} | ||
|
||
fun checkCarNameDuplication(cars: List<String>) { | ||
if (cars.toSet().size != cars.size) { | ||
throw IllegalArgumentException("자동차 이름이 중복입니다") | ||
} | ||
|
||
} | ||
fun checkCountIsNumber(inputCount: String) { | ||
try { | ||
inputCount.toInt() | ||
} catch (e: NumberFormatException) { | ||
throw IllegalArgumentException("정수만 입력가능합니다") | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package racingcar.View | ||
|
||
class InputView { | ||
fun inputCars() { | ||
println("경주할 자동차 이름을 입력하세요.(이름은 쉼표(,) 기준으로 구분)") | ||
} | ||
|
||
fun inputCount() { | ||
println("시도할 횟수는 몇 회인가요?") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. 오 문자열로 한 번 더 빼는 거군요. 감사합니다 |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package racingcar.View | ||
|
||
class OutputView { | ||
fun outputPrint() { | ||
println("실행 결과") | ||
} | ||
|
||
fun gameResult(carName: String, movingCount: Int) { | ||
println("$carName : ${"-".repeat(movingCount)}") | ||
} | ||
Comment on lines
+8
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 함수의 이름이 "게임의 결과"를 출력한다는 의미일까요 ? 그렇다면 |
||
|
||
fun winnerPrint(winners: List<String>) { | ||
println("최종 우승자 : ${winners.joinToString(", ")}") | ||
|
||
} | ||
Comment on lines
+12
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
보통 메인 함수가 가장 최상단에 위치하도록 하는 것 같습니다 :)
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.
그렇군요! 몰랐었는데 감사합니다!