-
Notifications
You must be signed in to change notification settings - Fork 550
[๐ ์ฌ์ดํด2 - ๋ฏธ์ (๋ธ๋์ญ ๋ฒ ํ )] ์นด์ผ ๋ฏธ์ ์ ์ถํฉ๋๋ค. #1121
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
base: choiyoung69
Are you sure you want to change the base?
Changes from all commits
87aee51
393a2d2
522d292
5693e1b
680e615
32eeef4
5a63634
8f1e0eb
e204224
bb050ef
5b79b75
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,55 +1,44 @@ | ||
| package domain.game; | ||
|
|
||
| import java.util.LinkedHashMap; | ||
| import domain.player.Dealer; | ||
| import domain.player.Gambler; | ||
| import domain.player.Gamblers; | ||
| import java.util.Collections; | ||
| import java.util.Map; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| public class GamblersGameResult { | ||
|
|
||
| private Map<String, GameResult> gamblersResult; | ||
| private Map<String, Long> gamblersResult; | ||
|
|
||
| public GamblersGameResult(int dealerScore, Map<String, Integer> gameResults) { | ||
| this.gamblersResult = gameResults.entrySet() | ||
| .stream() | ||
| .collect(Collectors.toMap(Map.Entry::getKey, | ||
| entry -> GameResult.determine( | ||
| dealerScore, | ||
| entry.getValue()), | ||
| (a, b) -> a, LinkedHashMap::new)); | ||
| } | ||
|
|
||
| public GameResult getMatchResult(String name) { | ||
| return gamblersResult.get(name); | ||
| } | ||
| public GamblersGameResult(Dealer dealer, Gamblers gamblers) { | ||
| int dealerTotalScore = dealer.getTotalScore(); | ||
|
|
||
| public int countDealerWin() { | ||
| return (int) gamblersResult.values() | ||
| this.gamblersResult = gamblers.getGamblers() | ||
| .stream() | ||
| .filter(result -> result == GameResult.LOSE) | ||
| .count(); | ||
| .collect(Collectors.toMap(Gambler::getName, gambler -> { | ||
| GameResult gameResult = GameResult.determine(dealerTotalScore, gambler.getTotalScore()); | ||
| if (gameResult == GameResult.WIN && gambler.isBlackJack()) { | ||
| return gambler.getAmount() * 3 / 2; | ||
| } | ||
| if(gameResult == GameResult.WIN) return gambler.getAmount(); | ||
| if(gameResult == GameResult.LOSE) return -gambler.getAmount(); | ||
| return 0L; | ||
| })); | ||
| } | ||
|
Comment on lines
+17
to
28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๋ฐ๋ณต๋ If๋ฅผ ์ด๋ป๊ฒ ์ค์ผ ์ ์์๊น์? |
||
|
|
||
| public int countDealerLose() { | ||
| return (int) gamblersResult.values() | ||
| public Long getDealerResult() { | ||
| return -gamblersResult.values() | ||
| .stream() | ||
| .filter(result -> result == GameResult.WIN) | ||
| .count(); | ||
| .mapToLong(Long::longValue) | ||
| .sum(); | ||
| } | ||
|
|
||
| public int countDealerDraw() { | ||
| return (int) gamblersResult | ||
| .values() | ||
| .stream() | ||
| .filter(result -> result == GameResult.DRAW) | ||
| .count(); | ||
| public Long getMatchResult(String name) { | ||
| return gamblersResult.get(name); | ||
| } | ||
|
|
||
| public Map<String, String> getResultInfo() { | ||
| return gamblersResult.entrySet() | ||
| .stream() | ||
| .collect(Collectors.toMap(Map.Entry::getKey, | ||
| entry -> entry.getValue().getGameResult(), | ||
| (a, b) -> a, LinkedHashMap::new | ||
| )); | ||
| public Map<String, Long> getResultInfo() { | ||
| return Collections.unmodifiableMap(gamblersResult); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,19 @@ | ||
| package domain.player; | ||
|
|
||
| import domain.player.attribute.Hand; | ||
| import domain.player.attribute.Money; | ||
| import domain.player.attribute.Name; | ||
|
|
||
| public class Gambler extends Participant{ | ||
| public Gambler(String name) { | ||
| super(name); | ||
|
|
||
| private final Money betAmount; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gambler๊ฐ Money๋ฅผ ๊ฐ์ง๋๋ก ๊ตฌ์ฑํ ์ด์ ๋ ๋ฌด์์ธ๊ฐ์? |
||
|
|
||
| public Gambler(Name name, Hand hand, Money betAmount) { | ||
| super(name, hand); | ||
| this.betAmount = betAmount; | ||
| } | ||
|
|
||
| public Long getAmount() { | ||
| return betAmount.getBetAmount(); | ||
| } | ||
|
Comment on lines
7
to
18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ์๊ฑฐ ์ ๊ฐ ์ด์ ๋ฆฌ๋ทฐ์์ ๋์น๊ธด ํ๋๋ฐ ์ปจ๋ฒค์ ๋ง์ถ๋ฉด ์ข์ ๊ฒ ๊ฐ๋ค์! |
||
| } | ||
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.
์๊ตฌ์ฌํญ์ ๊ผผ๊ผผํ๊ฒ ์ ์ ๋ฆฌํ์๋ค์ ๐