Open
Conversation
Wordbe
requested changes
Dec 11, 2024
Wordbe
left a comment
There was a problem hiding this comment.
블랙잭 미션을 빠르게 구현해주셨네요.
고생하셨습니다!
코멘트 드린 내용을 확인해보시고, 가능하신 부분은 반영 부탁드립니다.
감사합니다
Comment on lines
+38
to
+51
| private fun calculatePlayerResult( | ||
| player: Player, | ||
| dealerScore: Int, | ||
| dealerBlackjack: Boolean, | ||
| ): Int { | ||
| val playerBlackjack = player.isBlackjack() | ||
| return when { | ||
| player.getTotalValue() > BUST_THRESHOLD -> -player.getBettingAmount() | ||
| dealerScore > BUST_THRESHOLD -> player.getBettingAmount() | ||
| dealerBlackjack && playerBlackjack -> 0 | ||
| playerBlackjack -> (player.getBettingAmount() * BLACKJACK_MULTIPLIER).toInt() | ||
| player.getTotalValue() > dealerScore -> player.getBettingAmount() | ||
| else -> -player.getBettingAmount() | ||
| } |
There was a problem hiding this comment.
Score 라는 객체를 만들어 일부 혹은 전체 기능의 일을 위임해보면 어떨까요?
Comment on lines
+28
to
+35
| val playerResults = | ||
| participants.players.getPlayers() | ||
| .associate { player -> | ||
| player.name to calculatePlayerResult(player, dealerScore, dealerBlackjack) | ||
| } | ||
|
|
||
| val dealerProfit = playerResults.values.sum() * -1 | ||
| return playerResults + ("Dealer" to dealerProfit) |
| player.name to calculatePlayerResult(player, dealerScore, dealerBlackjack) | ||
| } | ||
|
|
||
| val dealerProfit = playerResults.values.sum() * -1 |
| class Player(val name: String) : Participant() | ||
| class Player( | ||
| val name: String, | ||
| private var bettingAmount: Int, |
Comment on lines
+7
to
+9
| fun getBettingAmount(): Int { | ||
| return bettingAmount | ||
| } |
There was a problem hiding this comment.
코틀린은 외부에서 사용할 게터는 자동으로 정의해주기 때문에 필요없어보여요 😀
|
|
||
| fun getBettingAmount(playerName: String): Int { | ||
| println("$playerName 의 배팅 금액은?") | ||
| return readlnOrNull()?.toIntOrNull() ?: 0 |
Comment on lines
7
to
+9
| class PlayersTest : StringSpec({ | ||
| "Players should distribute two cards to each player" { | ||
| val players = Players(listOf(Player("pobi"), Player("jason"))) | ||
| val players = Players(listOf(Player("pobi", 1000), Player("jason", 1000))) |
There was a problem hiding this comment.
players 도 getter 가 있는데, 코틀린 기본 게터를 사용해보는게 어떨까요?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
안녕하세요 리뷰어님 🙂
이번 PR에서는 Step4 블랙잭(베팅) 기능들을 구현해 추가했습니다
이번 단계도 잘 부탁드립니다! 🙇