Skip to content
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

[둘리] 2단계 자동차 경주 제출합니다. #68

Merged
merged 12 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor(Constants, InputView, OutputView, RaceGame): 네이밍 변경
  • Loading branch information
hyemdooly committed Feb 14, 2023
commit 4e8ad5581a02b74816ba502d85aef985d882a0b4
10 changes: 5 additions & 5 deletions src/main/kotlin/controller/RaceGame.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class RaceGame(private val outputView: OutputView, private val inputView: InputV
fun run() {
outputView.outputCarNames()
val cars = Cars(inputCarNames())
outputView.outputTryNumber()
val tryNumber = inputTryNumber().toInt()
outputView.outputNumber()
val tryNumber = inputNumber().toInt()
outputView.outputResults()
repeat(tryNumber) {
tryMove(cars)
Expand All @@ -38,11 +38,11 @@ class RaceGame(private val outputView: OutputView, private val inputView: InputV
return input
}

private fun inputTryNumber(): String {
var input = inputView.inputTryNumber()
private fun inputNumber(): String {
var input = inputView.inputNumber()
while (input.isNullOrBlank() || input.contains("[ERROR]")) {
outputView.outputErrorMessage(input ?: Constants.INPUT_IS_NULL)
input = inputView.inputTryNumber()
input = inputView.inputNumber()
}
return input
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/util/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package util

object Constants {
const val INPUT_CAR_NAME = "경주할 자동차 이름을 입력하세요(이름은 쉼표(,)를 기준으로 구분)."
const val INPUT_TRY_NUMBER = "시도할 횟수는 몇 회인가요?"
const val INPUT_NUMBER = "시도할 횟수는 몇 회인가요?"
const val OUTPUT_RESULT = "실행 결과"
const val OUTPUT_WINNER = "최종 우승자: "
const val INPUT_NAME_SIZE_ERROR_MESSAGE = "[ERROR] 자동차 이름의 길이가 5를 초괴합니다."
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/view/InputView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class InputView {
return input
}

fun inputTryNumber(): String? {
fun inputNumber(): String? {
var input = readlnOrNull()
runCatching {
Validator().checkTryNumber(input)
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/view/OutputView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class OutputView {
println(Constants.INPUT_CAR_NAME)
}

fun outputTryNumber() {
println(Constants.INPUT_TRY_NUMBER)
fun outputNumber() {
println(Constants.INPUT_NUMBER)
}

fun outputResults() {
Expand Down