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단계 - 블랙잭 #682

Open
wants to merge 10 commits into
base: hyotaek-jang
Choose a base branch
from
Open
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
feat: add inputView
HyoTaek-Jang committed Nov 28, 2023
commit 8e35001d3a7c28cbec2c33d4e0f9fd8b131f47f1
4 changes: 2 additions & 2 deletions src/main/kotlin/blackjack/README.md
Original file line number Diff line number Diff line change
@@ -8,9 +8,9 @@
- [ ] A는 1 또는 11로 계산할 수 있다.
- [x] J, Q, K는 각각 10으로 계산한다.
- [ ] 게임에 참여할 사람의 이름은 쉼표(,)를 기준으로 구분한다.
- [ ] 게임을 시작하면 각 플레이어는 각자 두 장의 카드를 지급 받는다.
- [x] 게임을 시작하면 각 플레이어는 각자 두 장의 카드를 지급 받는다.
- [ ] 받은 카드를 출력한다.
- [ ] 카드 숫자를 모두 합쳐 21을 초과하지 않으면 카드를 더 받을 수 있다.
- [ ] 한 사용자의 받기가 끝나면 다음 사용자로 넘어간다.
- [ ] 예는 y, 아니오는 n을 입력한다.
- [x] 예는 y, 아니오는 n을 입력한다.
- [ ] 카드를 받을 때마다 현재 갖고 있는 카드를 출력한다.
16 changes: 16 additions & 0 deletions src/main/kotlin/blackjack/view/InputView.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package blackjack.view

object InputView {
private const val DELIMITER = ","
private val RESPONSE_MAP = mapOf("y" to true, "n" to false)

fun inputNames(): List<String> {
println("게임에 참여할 사람의 이름을 입력하세요.(쉼표 기준으로 분리)")
return readln().split(DELIMITER)
}

fun inputHitOrStand(name: String): Boolean {
println("${name}는 한장의 카드를 더 받겠습니까?(예는 y, 아니오는 n)")
return RESPONSE_MAP[readln()] ?: throw IllegalArgumentException("잘못된 입력입니다.")
}
}