-
Notifications
You must be signed in to change notification settings - Fork 550
[๐ ์ฌ์ดํด2 - ๋ฏธ์ (๋ธ๋์ญ ๊ฒ์ ์คํ)] ์๋ก ๋ฏธ์ ์ ์ถํฉ๋๋ค. #1109
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
Open
sun007021
wants to merge
29
commits into
woowacourse:sun007021
Choose a base branch
from
sun007021:step2
base: sun007021
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+444
โ253
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
cfb5d7b
fix: ์นด๋ ๋ฝ๊ธฐ ์ค bust๋๋ฉด ์ฆ์ ํด๋น ํด ์ข
๋ฃํ๋๋ก ์์
sun007021 72fbe0a
docs: ๋ฐฐํ
๊ธฐ๋ฅ ๋ชฉ๋ก ์ถ๊ฐ
sun007021 152762a
test: ํ๋ ์ด์ด ๋ธ๋์ญ ํ๋จ
sun007021 f7b8de7
feat: ํ๋ ์ด์ด๊ฐ ๋ธ๋์ญ์ธ์ง ํ๋จ
sun007021 386cdfa
refactor: Game๋ด ์ผ๋ถ ํ์ ๋ฉ์๋ static์ผ๋ก ์์
sun007021 5a9a8d3
test: ํ๋ ์ด์ด๊ฐ ๋ธ๋์ญ์ด ์๋ ์ ์๋ก ์น๋ฆฌ์ ์์ต ๊ณ์ฐ
sun007021 4780292
feat: ํ๋ ์ด์ด๊ฐ ๋ธ๋์ญ์ด ์๋ ์ ์๋ก ์น๋ฆฌ์ ์์ต ๊ณ์ฐ
sun007021 50455df
test: ํ๋ ์ด์ด๊ฐ ๋ธ๋์ญ์ผ๋ก ์น๋ฆฌ์ ์์ต์ ๋ฐฐํ
๊ธ์ก์ 1.5๋ฐฐ
sun007021 bf80e3e
feat: ํ๋ ์ด์ด๊ฐ ๋ธ๋์ญ์ผ๋ก ์น๋ฆฌ์ ์์ต์ ๋ฐฐํ
๊ธ์ก์ 1.5๋ฐฐ
sun007021 cafc932
style: LOSE ์คํ ์์
sun007021 193dfd2
test: ํ๋ ์ด์ด ํจ๋ฐฐ์ ์์ต ๊ณ์ฐ
sun007021 0955ddb
test: ๋ฌด์น๋ถ์ ์์ต์ 0
sun007021 37b1b7a
refactor: ์นด๋ ๋ถ๋ฐฐ ์์กด์ฑ ๋ฐ ์ฑ
์ ๋ณ๊ฒฝ
sun007021 d28edad
refactor: ๊ฒ์ ๊ฐ์ฒด ์ฑ
์ ์ถ๊ฐ
sun007021 590b602
test: ์ ์ฒด ์ฐธ๊ฐ์ ์์ต ๊ณ์ฐ
sun007021 b62c344
refactor: ๋ฐฐํ
๊ธ์ก ๋ฐ ์์ต ๊ณ์ฐ ์ฑ
์ Player๋ก ๋ณ๊ฒฝ
sun007021 7f65b27
refactor: ๋ธ๋์ญ ํ๋ณ ์ฑ
์ ์ด๋
sun007021 e36594e
feat: ์ ์ฒด ์์ต ๊ณ์ฐ
sun007021 8fb3ad3
docs: ๋ธ๋์ญ ํ๋จ ๊ธฐ๋ฅ ๋ช
์ธ ์ถ๊ฐ
sun007021 feb159e
feat: ๋ฐฐํ
๊ธ์ก ์
๋ ฅ ์ถ๊ฐ
sun007021 42c92e0
fix: ๋ฐฐํ
๊ธ์ก ์ฌ์
๋ ฅ ์ฒ๋ฆฌ์ input ๋ค์ ์๋ฐ์ ๋ฌดํ๋ฃจํ ๋ฐ์ ์์
sun007021 23997d6
feat: ์ต์ข
์์ต ๊ฒฐ๊ณผ ์ถ๋ ฅ
sun007021 780658f
chore: ๋ฏธ์ฌ์ฉ ํด๋์ค ๋ฐ import๋ฌธ ์ญ์
sun007021 4daa210
chore: record ์ฌ์ฉ์ผ๋ก ๋ถํ์ ๋ฉ์๋ ์ ๊ฑฐ
sun007021 63b8ebd
refactor: countAces ๋ฉ์๋ depth์ด๊ณผ ์คํธ๋ฆผ ์ฌ์ฉ์ผ๋ก ๋ณ๊ฒฝ
sun007021 795f55f
refactor: rank, shape String -> Enum ์ฌ์ฉ ๋ณ๊ฒฝ
sun007021 53852e2
refactor: card aceํ์ธ ์ฑ
์ ๋ถ๋ฆฌ
sun007021 aca7d15
refactor: dto ํจํค์ง ๋ถ๋ฆฌ
sun007021 0d7cf27
refactor: ๋ฐฐํ
๋ฐ ์์ต๊ธ ๊ณ์ฐ BigDecimal ์ฌ์ฉ์ผ๋ก ๋ณ๊ฒฝ
sun007021 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,46 +1,17 @@ | ||
| package blackjack.domain; | ||
|
|
||
| public record Card(String rank, String shape) { | ||
| public record Card(Rank rank, Shape shape) { | ||
|
|
||
| public String getDisplayName() { | ||
| return rank + shape; | ||
| return rank.getName() + shape.getName(); | ||
| } | ||
|
|
||
| public int translateToScore() { | ||
| if (rank.equals("J") || rank.equals("Q") || rank.equals("K")) { | ||
| return 10; | ||
| } | ||
| if (rank.equals("A")) { | ||
| return 11; | ||
| } | ||
|
|
||
| return convertToNumber(rank); | ||
| } | ||
|
|
||
| private static int convertToNumber(String rank) { | ||
| int score; | ||
| try { | ||
| score = Integer.parseInt(rank); | ||
| } catch (IllegalArgumentException e) { | ||
| throw new IllegalArgumentException("J,Q,K ์ธ์ ๋ฌธ์์ด ์ ๋ ฅ์ ๋ถ๊ฐ๋ฅํฉ๋๋ค."); | ||
| } | ||
|
|
||
| if (score > 10 || score < 2) { | ||
| throw new IllegalArgumentException("2~10 ์ฌ์ด์ ์ซ์๋ง ๊ฐ๋ฅํฉ๋๋ค."); | ||
| } | ||
| return score; | ||
| return rank.getScore(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
| if (this == o) { | ||
| return true; | ||
| } | ||
| if (!(o instanceof Card card)) { | ||
| return false; | ||
| } | ||
| return rank.equals(card.rank) && | ||
| shape.equals(card.shape); | ||
| public boolean isAce() { | ||
| return rank == Rank.ACE; | ||
| } | ||
|
|
||
| } |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,41 @@ | ||
| package blackjack.domain; | ||
|
|
||
|
|
||
| import java.math.BigDecimal; | ||
|
|
||
| public class Player extends Participant { | ||
| private static final BigDecimal BLACKJACK_PROFIT_RATE = BigDecimal.valueOf(1.5); | ||
|
|
||
| private final String name; | ||
| private final BigDecimal bettingAmount; | ||
|
|
||
| public Player(String name) { | ||
| this(name, BigDecimal.valueOf(0)); | ||
| } | ||
|
|
||
| public Player(String name, BigDecimal bettingAmount) { | ||
| this.name = name; | ||
| this.bettingAmount = bettingAmount; | ||
| } | ||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public BigDecimal calculateProfit(ScoreCompareResult compareResult) { | ||
| if (compareResult == ScoreCompareResult.PLAYER_WIN) { | ||
| return calculateProfitWhenPlayerWins(); | ||
| } | ||
| if (compareResult == ScoreCompareResult.PLAYER_LOSE) { | ||
| return bettingAmount.negate(); | ||
| } | ||
| return BigDecimal.ZERO; | ||
| } | ||
|
|
||
| private BigDecimal calculateProfitWhenPlayerWins() { | ||
| if (isBlackjack()) { | ||
| return (bettingAmount.multiply(BLACKJACK_PROFIT_RATE)); | ||
| } | ||
| return bettingAmount; | ||
| } | ||
| } |
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package blackjack.domain; | ||
|
|
||
| import java.math.BigDecimal; | ||
| import java.util.Map; | ||
|
|
||
| public record ProfitResults(BigDecimal dealerProfit, Map<Player, BigDecimal> playerProfit) { | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package blackjack.domain; | ||
|
|
||
| public enum Rank { | ||
| TWO("2", 2), | ||
| THREE("3", 3), | ||
| FOUR("4", 4), | ||
| FIVE("5", 5), | ||
| SIX("6", 6), | ||
| SEVEN("7", 7), | ||
| EIGHT("8", 8), | ||
| NINE("9", 9), | ||
| TEN("10", 10), | ||
| JACK("J", 10), | ||
| QUEEN("Q", 10), | ||
| KING("K", 10), | ||
| ACE("A", 11); | ||
|
|
||
| private final String name; | ||
| private final int score; | ||
|
|
||
| Rank(String name, int score) { | ||
| this.name = name; | ||
| this.score = score; | ||
| } | ||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public int getScore() { | ||
| return score; | ||
| } | ||
| } |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package blackjack.domain; | ||
|
|
||
| public enum Shape { | ||
| HEART("ํํธ"), | ||
| DIAMOND("๋ค์ด์๋ชฌ๋"), | ||
| CLUB("ํด๋ก๋ฒ"), | ||
| SPADE("์คํ์ด๋"); | ||
|
|
||
| private final String name; | ||
|
|
||
| Shape(String name) { | ||
| this.name = name; | ||
| } | ||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
| } |
2 changes: 1 addition & 1 deletion
2
...ava/blackjack/domain/PlayerCardsName.java โ ...n/java/blackjack/dto/PlayerCardsName.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package blackjack.domain; | ||
| package blackjack.dto; | ||
|
|
||
| import java.util.List; | ||
|
|
||
|
|
||
2 changes: 1 addition & 1 deletion
2
...ackjack/domain/PlayerFinalCardsScore.java โ .../blackjack/dto/PlayerFinalCardsScore.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package blackjack.domain; | ||
| package blackjack.dto; | ||
|
|
||
| import java.util.List; | ||
|
|
||
|
|
||
Oops, something went wrong.
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.
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.
์ ๊ท ์๊ตฌ์ฌํญ์ ์ ์ ๋ฆฌํ์๋ค์ ๐