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

[자동차 경주 게임] 박세아 미션 제출합니다. #221

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 8 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# 기능 구현 목록
- 사용자 자동차 입력
- 자동차 객체 생성
- 사용자 시도 횟수 입력
- 무작위 값 생성 후 전진 여부 결정
- 자동차 전진
- 실행 결과 출력
- 전반전인 게임 진행
26 changes: 26 additions & 0 deletions src/main/kotlin/racingcar/Car.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import camp.nextstep.edu.missionutils.Randoms

class Car {
var name: String = ""
var score: Int = 0

constructor(name: String) {
this.name = name
}

fun confirmProgress(): Boolean {
var randomNumber = Randoms.pickNumberInRange(0, 9)

if (randomNumber >= 4) {
return true
}
return false
}

fun progressScore(progressBool: Boolean) {
if (progressBool) {
this.score += 1
}
}

}
22 changes: 22 additions & 0 deletions src/main/kotlin/racingcar/User.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import camp.nextstep.edu.missionutils.Console

class User {
var carNameList: List<String> = emptyList<String>()
var tryCount: Int = 0

fun inputCarNames() {
print("경주할 자동차 이름을 입력하세요. (이름은 쉼표(,)로 구분)")
var names = Console.readLine()
separateCommas(names)
}

fun separateCommas(names: String) {
val carNameList = names.split(",").toList()
}

fun inputTryCount() {
print("시도할 횟수는 몇 회인가요?")
this.tryCount = Console.readLine().toInt()
}

}