-
Notifications
You must be signed in to change notification settings - Fork 550
[π μ¬μ΄ν΄2 - λ―Έμ (λΈλμ λ² ν )] μ΄λ λ―Έμ μ μΆν©λλ€. #1127
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: jyl35
Are you sure you want to change the base?
Changes from all commits
819bff5
258ba6f
0e0783a
aeb1bd5
e2ec1e6
8ef0716
5b571dd
6b2d824
8528c2d
9f838fb
45e3509
bc0a00a
3308686
37ec062
63d3e91
bd43438
e429be5
9d85b36
a9798d8
c496ce9
96fa9fe
880fc5d
2af5859
52be408
9be9861
bcc7fca
e7d490a
d4cc1ad
132e809
ab20a64
dd7d869
88ecc99
7c01058
93b9937
47725e2
96872c3
426cc5e
22ab1ca
b8375da
2b3f0e0
2d7bfcf
53d42bd
457c5a6
9139edc
1351ebb
12afb7e
ca8d35d
b39a1d9
4bcf5fb
2a4b988
7f2ca54
b702593
2490ef6
3c24d3f
d88d116
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,42 +1,59 @@ | ||
| package application; | ||
|
|
||
| import domain.Card; | ||
| import domain.card.Card; | ||
| import domain.GameTable; | ||
| import application.dto.RoundResult; | ||
| import domain.StandardDeck; | ||
| import domain.dto.GameResult; | ||
| import domain.dto.MemberStatus; | ||
| import domain.member.Money; | ||
| import dto.RoundResult; | ||
| import domain.card.StandardDeck; | ||
| import dto.GameResult; | ||
| import dto.MemberStatus; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| public class BlackjackService { | ||
|
|
||
| private GameTable gameTable; | ||
| private final GameTable gameTable; | ||
|
|
||
| public BlackjackService() { | ||
| public BlackjackService(Map<String, Integer> playerBetAmounts) { | ||
| Map<String, Money> playerBets = new HashMap<>(); | ||
| for (String name : playerBetAmounts.keySet()) { | ||
| Money betMoney = new Money(playerBetAmounts.get(name)); | ||
| playerBets.put(name, betMoney); | ||
| } | ||
| this.gameTable = new GameTable(playerBets, new StandardDeck()); | ||
| gameTable.distributeInitCard(); | ||
| } | ||
|
|
||
| public void initializeGame(List<String> playerNames) { | ||
| this.gameTable = new GameTable(playerNames, new StandardDeck()); | ||
| gameTable.distributeInitCard(); | ||
| public boolean isFinishedByName(String playerName) { | ||
| return gameTable.isPlayerFinished(playerName); | ||
|
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. getGameTable()λ₯Ό μ°λ κ²½μ°μ gameTableλ₯Ό μ°λ κ²½μ°κ° νΌμ¬λμ΄ μλ€μ.
Author
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. λμΉ λΆλΆμΈ κ² κ°μ΅λλ€..! κ°μ¬ν©λλ€! |
||
| } | ||
|
|
||
| public RoundResult startOneRound(String memberName) { | ||
| List<Card> playerCards = gameTable.drawForMember(memberName); | ||
|
|
||
| boolean isBust = gameTable.checkBust(memberName); | ||
| boolean isBust = gameTable.isPlayerBust(memberName); | ||
|
|
||
| return new RoundResult(playerCards, isBust); | ||
| } | ||
|
|
||
| public void endPlayerRound(String playerName) { | ||
| gameTable.changePlayerState(playerName); | ||
| } | ||
|
|
||
| public boolean checkDealerDrawable() { | ||
| return gameTable.drawForDealer(); | ||
| } | ||
|
|
||
| public List<MemberStatus> getMemberStatuses() { | ||
| return gameTable.checkMemberStatuses(); | ||
| return gameTable.getMemberStatuses(); | ||
| } | ||
|
|
||
| public List<GameResult> getGameResults() { | ||
| return gameTable.checkGameResult(); | ||
| Map<String, Integer> profits = gameTable.getFinalProfits(); | ||
| return profits.entrySet().stream() | ||
| .map(entry -> new GameResult(entry.getKey(), entry.getValue())) | ||
| .toList(); | ||
| } | ||
| } | ||
This file was deleted.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
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.
λ―Έμ μꡬμ¬νμ μ μΆ κΈ°νμ΄ λͺ μλμ΄μμ§ μμλ€λ©΄, μ¬κ³Όνμ§ μμΌμ λ λ©λλ€.
μ λ μ κ²½μ°μ§ μλ νΈμ΄μ§λ§, λ€λ₯Έ 리뷰μ΄λ₯Ό λ§λ¬μ λλ μνΈκ°μ μΌμ μ μν΄ μ€λ 걸릴 κ² κ°μΌλ©΄ DMμ λ¨κ²¨λλ λ°©λ²λ μμ κ² κ°μμ.
μ μ΄λ―Έλ‘ μΆ©λΆν©λλ€.
μΈμ€ν΄μ€ λ³μ 3κ° μ νκ³Ό μμ ꡬ쑰μμμ μΉ΄μ΄νΈ κΈ°μ€
λλ―Έν° λ²μΉ(Law of Demeter)κ³Ό μλΉμ€ κ³μΈ΅μ μ± μ λ²μ
ν μ€νΈ μ½λμ μ μ°μ±κ³Ό νμ₯μ± (OCP)
λΆλ³ κ°μ²΄(Immutable Object)μ μν°ν°μ νλ λ³κ²½
λλ μ§ μ΄λ€ κ²μ μ ννλ νΈλ μ΄λμ€νμ λλ€. μ₯/λ¨μ μ λΉκ΅νμ λ μ₯μ μ΄ λ ν° κ²½μ°μλ§ μ¬μ©νλ©΄ λ©λλ€.
Uh oh!
There was an error while loading. Please reload this page.
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.
μ¬μ€ μμμΌκΉμ§ Mergeκ° λλ κ²μ λͺ©νλ‘ νλ κ² μΈμλ μΌμ μ΄ λ°λ‘ λͺ μλμ΄μμ§ μμ΅λλ€. νμ§λ§ μ£Όλ§μ ν΄μ νμλ κ²μ κ³ λ €νμ λ νμΌμ 리뷰 μμ² λ리λκ² λ«λ€κ³ νλ¨νμ¬ μ λ κ² λ§μ λλ Έμ΅λλ€. μ‘°μΈ κ°μ¬ν©λλ€!
μμ ꡬ쑰μμ λ°μνλ νλ μΉ΄μ΄νΈμ 'is-a' κ΄κ³μ λν μ μ΄λ―Έμ μ‘°μΈμ λ°νμΌλ‘ μμμ μ κ±°νκ³ μ‘°ν©μΌλ‘ μ ννκ² μ΅λλ€.
κ³΅ν΅ λ‘μ§μΈ μ΄λ¦κ³Ό μν κ΄λ¦¬λ₯Ό MemberInfoλΌλ μΌλ° ν΄λμ€λ‘ λΆλ¦¬νκ³ , Dealerμ Playerκ° μ΄λ₯Ό μμ νλλ‘ μ€κ³νκ² μ΅λλ€.
GameTableμ μ κ±°νλ κ²λ κ³ λ €ν΄μ 리ν©ν λ§ μ§ννκ² μ΅λλ€!
μν ν¨ν΄μ λμ νλ©° λΆκΈ°λ¬Έμ λ§μ΄ μ κ±°νμμλ, Stayμ Blackjack μνμμ μμ΅λ₯ μ κ²°μ ν λ μ¬μ ν μλλ°©μ νμ μ νμΈνλ instanceofκ° λ¨μμμ΄ μμ ν OCPλ₯Ό λ¬μ±νμ§ λͺ»νλ€λ μ μ μ΄ν΄νμ΅λλ€.
μ΄ λΆλΆμ ν΄κ²°νκΈ° μν΄ μνλΌλ¦¬ λ©μμ§λ₯Ό μ£Όκ³ λ°μΌλ©° μΉν¨λ₯Ό κ²°μ νκ² νκ±°λ, μν ν¨ν΄μ isBust(), isBlackjack()λ₯Ό μΆκ°νμ¬ νμ μ μ§μ λ¬»μ§ μλ λ°©μμΌλ‘ 리ν©ν°λ§ν΄ λ³΄κ² μ΅λλ€. μΆν νμ₯μ±κΉμ§ κ³ λ €ν μμ ν OCP ꡬ쑰μ λν΄ λ κ³ λ―Όν΄ λ³΄κ² μ΅λλ€!
μμΌλ‘λ μ₯/λ¨μ μ λΉκ΅νμ¬ κ³μΈ΅μ λ§κ² λμ νλ λ°©μμΌλ‘ μ§ννκ² μ΅λλ€. κ°μ¬ν©λλ€!