-
Notifications
You must be signed in to change notification settings - Fork 550
[๐ ์ฌ์ดํด2 - ๋ฏธ์ (๋ธ๋์ญ ๋ฒ ํ )] ๋ชจ์ ๋ฏธ์ ์ ์ถํฉ๋๋ค. #1124
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: picetea44
Are you sure you want to change the base?
Changes from all commits
c8daa3f
6cdbba2
9ff221c
648fe9b
cbedd0e
d17084e
c102d24
abffda7
6107d0d
16188ab
3fe7c1d
ba63f5b
490cf85
3060aa5
3952e53
e35b6f6
d36a0d0
9bce798
63ce635
e3987cb
5b5a0b1
d3f91cc
4624b1f
6452da9
1429d04
5b7c169
dd01040
496bd15
e0ed3a9
5f39da1
282a2f7
a767b97
36f2851
688c160
f07c141
5f8f1c7
4cb6da4
4494c5c
a619629
fb52804
0befc31
12e45c1
8f0f62d
e614644
083ab13
2a13394
d4c3f6e
8fbccba
c740604
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 |
|---|---|---|
|
|
@@ -18,76 +18,70 @@ | |
| - [x] 4 | ||
| - [ ] 5 (์๋ฒฝํ๊ฒ ์ถฉ์กฑ) | ||
|
|
||
| ### ์ ํํ ์ ์์ ์ด์ ๋ฅผ ์ ์ด์ฃผ์ธ์. | ||
| ์ฒ์์ผ๋ก TDD๋ฅผ ์ ์ฉํ์ฌ ์งํํด๋ดค์ต๋๋ค. ์ ์ฒด์ ์ธ ์ค๊ณ ์์ด ์ผ๋จ ๋์๊ฐ๋ ๊ธฐ๋ฅ์ ๋ง๋ค๊ณ ํ ์คํธ๋ฅผ ํ๋ค๋ ๊ฐ๋ ์ด ๋ง์ด ์์ํ๋ ๊ฒ ๊ฐ์ต๋๋ค. | ||
| ๊ทธ๋ก์ธํด ๋ถ๋ถ์ ์ผ๋ก indent๋ ๋ฌธ์์ด ํฌ์ฅ์ด ์๋ฒฝํ๊ฒ ์ ์ฉ๋์ง ๋ชปํ๋ ๊ฒ ๊ฐ์ต๋๋ค. | ||
| <!-- ์ด์ ์์ฑ --> | ||
|
|
||
|
|
||
| ## ์ด๋ค ๋ถ๋ถ์ ์ง์คํ์ฌ ๋ฆฌ๋ทฐํด์ผ ํ ๊น์? | ||
|
|
||
| --- | ||
| ### ์ฃผ์ 1 - TDD ๊ด๋ จ | ||
| ๋ฏธ์ ์ด๊ธฐ, ์ ์ฒด์ ์ธ ์ค๊ณ๊ฐ ๋จธ๋ฆฟ์์ ์๋ฒฝํ ๊ทธ๋ ค์ง์ง ์์ ์ํ์์ TDD๋ฅผ ์์ํ๋ ค๋ ์๋นํ ๋ง๋งํจ์ ๋๊ผ์ต๋๋ค. ๋์์ ๊ธฐ์ค์ผ๋ก ํ ์คํธ๋ฅผ ์์ฑํ๋ฉฐ ์ํฅ์์ผ๋ก ์ ๊ทผํ๋ ค ํ์ผ๋, ์ฌ๋ฌ ๊ฐ์ฒด๋ ๋ฉ์๋๊ฐ ๋ณต์กํ๊ฒ ์ํธ์์ฉํด์ผ ํ๋ ์ํฉ์์๋ ๊ทธ ๋์์ ๋จ์ ์์ฒด๊ฐ ๋ชจํธํ๊ฒ ๋ค๊ฐ์์ต๋๋ค. | ||
| ํ์ฌ ๊ตฌ์กฐ๋ Player โ CardBundle โ Card์ฒ๋ผ ๊ฐ์ฒด๊ฐ ์๋ก๋ฅผ ์ฐธ์กฐํ๊ณ ์๋๋ฐ, ์ผ๋ถ ๋ก์ง์์ ์ด๋ฏธ Player ๊ฐ์ฒด๋ฅผ ์ ๋ฌ๋ฐ๊ณ ์์์๋ ๋ถ๊ตฌํ๊ณ CardBundle์ ์ง์ ์ ๊ทผํด ์ ์๋ฅผ ๊ณ์ฐํ๋ ์ฝ๋๊ฐ ์์์ต๋๋ค. | ||
| ์ด ๊ฒฝ์ฐ ํน์ ํด๋์ค๊ฐ ์ฌ๋ฌ ๋๋ฉ์ธ์ ๋ด๋ถ ๊ตฌ์กฐ๋ฅผ ์๊ณ ์์ด์ผ ํ๋ค๋ ์ ์ด ๊ฑธ๋ ธ์ต๋๋ค. | ||
| ๊ทธ๋์ ์ธ๋ถ์์ CardBundle์ ์ง์ ์ ๊ทผํ๋ ๋์ , Player์๊ฒ ์ ์๋ฅผ ์์ฒญํ๊ณ Player๊ฐ ๋ด๋ถ์ ์ผ๋ก CardBundle์ ์์ํ๋ ๊ตฌ์กฐ๋ก ๋ณ๊ฒฝํ์ต๋๋ค. ์ด๋ ๊ฒ ํ๋ฉด ์ธ๋ถ์์๋ Player์ ๋ด๋ถ ๊ตฌ์กฐ๋ฅผ ์ ํ์๊ฐ ์์ด์ง๊ณ , ๋์ค์ ์นด๋ ๊ด๋ฆฌ ๋ฐฉ์์ด๋ ์ ์ ๊ณ์ฐ ๋ก์ง์ด ๋ฐ๋๋๋ผ๋ ๋ค๋ฅธ ๋๋ฉ์ธ์ด๋ ๋ ์ด์ด์ ๋ณ๊ฒฝ์ ์ค์ผ ์ ์์ง ์์๊น ์๊ฐํ์ต๋๋ค. | ||
| ๊ตฌํ์ ์งํํ๋ฉด์ ์ด๋ฐ ๋ฐฉ์์ด ์์ ๋ฉ์๋๋ผ๋ ๊ฐ๋ ๊ณผ๋ ์ฐ๊ฒฐ๋๋ค๋ ๊ฒ์ ์๊ฒ ๋์์ต๋๋ค. | ||
| ์ฌ์ดํด1 ๋ฆฌ๋ทฐ์์ ์ง์์ ๋ฐ์๊ฐ๋ ์ทจ์ง๋ณด๋ค ์ ์๊ฐ์ด ์๋๋ฅผ ์ค๋ํ ์ ์์์ง์ ์ด์ ์ ๋ง์ถฐ๋ณด๋ผ๋ ๋ง์์ ํด์ฃผ์ จ๋๋ฐ, ์ด๋ฒ์๋ ๊ทธ ์กฐ์ธ์ ๋ ์ฌ๋ฆฌ๋ฉฐ ์ ๋๋ฆ์ ๊ธฐ์ค์ผ๋ก ๊ตฌ์กฐ๋ฅผ ์ ํํด ๋ณด์์ต๋๋ค. | ||
| ์ ๊ฐ ์ด๋ฐ ๋ฐฉํฅ์ผ๋ก ์ ๊ทผํ ๊ฒ์ด ์ด๋ ์ ๋ ํ๋นํ ๋ฐฉํฅ์ธ์ง, ๋ ์ด๋ฐ ์ํฉ์์ ์ถ๊ฐ๋ก ๊ณ ๋ คํด ๋ณผ ๋งํ ๋ถ๋ถ์ด ์๋์ง๋ ์๊ฒฌ์ ๋ฃ๊ณ ์ถ์ต๋๋ค. | ||
|
|
||
| ํ์ ๊ณผ ์์ต ๊ณ์ฐ ์ฑ ์ ๋ถ๋ฐฐ์์ ๊ฒช์ ์ด๋ ค์๋ ์์์ต๋๋ค. | ||
| ๋ฒ ํ ๊ธฐ๋ฅ์ ๊ตฌํํ๋ฉด์ ํ์ ๊ฒฐ๊ณผ์ ๋ฒ ํ ๊ธ์ก์ ์ด์ฉํด ์์ต์ ๊ณ์ฐํ๋ ์ฑ ์์ ์ด๋์ ๋์ด์ผ ํ ์ง ๊ณ ๋ฏผ์ด ๋ง์์ต๋๋ค. | ||
| ์ฒ์์๋ ๊ด๋ จ ์ฑ ์์ Bet ๋๋ฉ์ธ์ ๋ชจ์ผ๋ ค๊ณ ์๊ฐํ์ต๋๋ค. ํ์ง๋ง ๊ตฌํ์ ์งํํ๋ฉด์ ํ์ ๋ก์ง, ํ๋ ์ด์ด ์ํ, ๋ฒ ํ ๊ธ์ก ๋ฑ ์ฌ๋ฌ ๋๋ฉ์ธ์ด ํจ๊ป ๊ด์ฌํ๊ฒ ๋์๊ณ , ์ด๋ ๊ฐ์ฒด์ ์ฑ ์์ ๋๋ ๊ฒ์ด ์์ฐ์ค๋ฌ์ด์ง ํ๋จํ๊ธฐ๊ฐ ์ฝ์ง ์์์ต๋๋ค. | ||
| ๊ทธ๋์ ์ฌ๋ฌ ๋ฐฉํฅ์ผ๋ก ๊ตฌ์กฐ๋ฅผ ๋ฐ๊ฟ ๋ณด๋ฉด์ ๊ณ์ ์์ ์ ์งํํ๋ ๊ฒ ๊ฐ์ต๋๋ค. ๊ทธ ๊ณผ์ ์์ ํน์ ๊ฐ์ฒด๊ฐ ๋๋ฌด ๋ง์ ์ ๋ณด๋ฅผ ์๊ฒ ๋๋ ๊ตฌ์กฐ๊ฐ ๋๊ธฐ๋ ํ๊ณ , ๋ฐ๋๋ก ์ฑ ์์ด ์ง๋์น๊ฒ ๋ถ์ฐ๋๋ ๋๋๋ ์์์ต๋๋ค. | ||
| ์ฌ๋ฌ ์๋๋ฅผ ๊ฑฐ์น ๋์ ํ์ฌ ๊ตฌ์กฐ๋ฅผ ์ ํํ๊ฒ ๋์์ง๋ง, ์ด ์ ํ์ด ์ต์ ์ธ์ง์ ๋ํด์๋ ์์ง ํ์ ์ด ์์ง๋ ์์ต๋๋ค. | ||
| ์๋ฃจ๊ฐ ๋ณด์๊ธฐ์๋ ์ด ๋ฌธ์ ๋ฅผ ๊ณ ๋ฏผํ๋ ๊ณผ์ ์์ ์ ๊ฐ ๋์น๊ณ ์๋ ๋ถ๋ถ์ด ์๋์ง, ํน์ ์ด๋ฐ ์ํฉ์์ ์ฑ ์์ ์์น๋ฅผ ํ๋จํ ๋ ์ด๋ค ๊ธฐ์ค์ผ๋ก ์ ๊ทผํ์๋์ง ๊ถ๊ธํฉ๋๋ค. | ||
|
Member
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. ์ฝ๋๋ฅผ ์ฝ๋๋ฐ์๋ ์ ํ ๋ถํธํ์ง ์์๊ณ , ์๊ตฌ์ฌํญ ์ถ๊ฐ์ ๋ง๊ฒ ์ ๋ฐ์ ์์ผ์ฃผ์ จ๋ค๊ณ ์๊ฐํด์. ๊ถ๊ธํ ๋ด์ฉ์ ๊ฐ ์ฝ๋ฉํธ์ ๋จ๊ฒจ๋๊ฒ ์ต๋๋ค. ๐๐ป |
||
|
|
||
| ์ฒ์์๋ ํ๋ก๊ทธ๋จ์ ํ๋ฆ์ ๋ฐ๋ผ ํฐ ๋จ์์์ ์์ ๋จ์๋ก ๊ธฐ๋ฅ์ ์ ์ํ๋ฉฐ ๋ด๋ ค์๋๋ฐ, ์ด ๊ณผ์ ์ด ๋ค์ ์ถ์์ ์ด๋ผ๋ ์๊ฐ์ด ๋ค์์ต๋๋ค. ํ์ ์์๋ ์ค๊ณ๊ฐ ๋ถํ์คํ ์ํฉ์์ ์ด๋ค ์ง์ ์ ์์์ ์ผ๋ก ์ก๊ณ ์ค๊ณ๋ฅผ ๊ตฌ์ฒดํํด ๋๊ฐ๋์ง, ๊ทธ๋ฆฌ๊ณ ๊ฐ์ฒด ๊ฐ์ ํ๋ ฅ์ด ํ์์ ์ธ ์ํฉ์์ TDD์ ๋ฆฌ๋ฌ์ ์ด๋ป๊ฒ ์ ์งํ์๋์ง ๊ถ๊ธํฉ๋๋ค. | ||
|
|
||
| ### ์ฃผ์ 2 - ํ ์คํธ๋ฅผ ์ํ ์ฝ๋ | ||
| ํ ์คํธ ๊ฐ๋ ์ฑ๊ณผ ๊ฒ์ฆ์ ์ํด ํ๋ก๋์ ์ฝ๋๋ฅผ ์ด๋๊น์ง ์์ ํด์ผ ํ๋์ง์ ๋ํด์๋ ๊น์ด ๊ณ ๋ฏผํ์ต๋๋ค. ์๋ฅผ ๋ค์ด, ์นด๋ ๋ฑ์์ ์นด๋๊ฐ ์ ๋๋ก ๋ฝํ๋์ง ํ์ธํ๊ธฐ ์ํด ์ค์ ๋ก์ง์์๋ ์ฐ์ด์ง ์๋ deck.size()์ ๊ฐ์ ๋ฉ์๋๋ฅผ ์ถ๊ฐํ๋ ์ํฉ์ด ์์์ต๋๋ค. | ||
|
|
||
| ์ด๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด 1) ๋ฌด์ํ๊ฒ 52๋ฒ์ draw()๋ฅผ ํธ์ถํ์ฌ ์์ธ๋ฅผ ํ์ธํ๋ ๋ฐฉ์, 2) ๋ด๋ถ ์ํ๋ฅผ ์ฐํํ์ฌ ๊ฒ์ฆํ๋ ๋ฐฉ์, 3) ์์๋ก ๋ฉ์๋๋ฅผ ๋ง๋ค๊ณ ์ถํ ์ญ์ ํ๋ ๋ฐฉ์ ๋ฑ์ ๊ณ ๋ คํด ๋ณด์์ต๋๋ค. ์ ๋ ํ์ฌ ํ ์คํธ์ ๋ช ํ์ฑ์ ์ํด ๋ฉ์๋๋ฅผ ์ ์งํ๋ ์ชฝ์ ํํ์ง๋ง, ์ด๊ฒ์ด ์ ์ ํ ๋ฐฉํฅ์ด ๋ง์์ง ์ฐ๋ ค๋๊ธฐ๋ ํฉ๋๋ค. ํ ์คํธ ๊ฐ๋ฅ์ฑ์ ๋์ด๊ธฐ ์ํด ํ๋ก๋์ ์ฝ๋๋ฅผ ๋ณ๊ฒฝํ๋ ๊ฒ์ ๋ํด ๋ฆฌ๋ทฐ์ด๋์ ์ด๋ค ๊ธฐ์ค์ ๊ฐ์ง๊ณ ๊ณ์ ๊ฐ์? | ||
|
|
||
| ### ์ฃผ์ 3 - ๋๋ฉ์ธ์ ๋ฐ๋ฅธ ์ํคํ ์ฒ | ||
| ๋ง์ง๋ง์ผ๋ก ๋ธ๋์ญ์ฒ๋ผ ๋๋ฉ์ธ ๋ก์ง์ด ๋ช ํํ๊ณ ๊ท๋ชจ๊ฐ ์์ ๊ฒฝ์ฐ, ์๋น์ค ๋ ์ด์ด์ ๋์ ์ด ๋ฐ๋์ ํ์ํ์ง ์๋ฌธ์ด ์๊ฒผ์ต๋๋ค. ํ์ฌ ๊ตฌ์กฐ์์๋ ์ปจํธ๋กค๋ฌ์ ๋๋ฉ์ธ ๋ชจ๋ธ๋ง์ผ๋ก๋ ์ถฉ๋ถํ ์คํ ํ๋ฆ์ ์ ์ดํ ์ ์๋ค๊ณ ๋๊ผ๊ณ , ๋จ์ํ ๊ณ์ธต ๊ตฌ์กฐ๋ฅผ ๋ง์ถ๊ธฐ ์ํด ์๋น์ค ๋ ์ด์ด๋ฅผ ๋๋ ๊ฒ์ ๋ถํ์ํ ์์ ์ฝ๋๋ง ์์ฐํ๋ค๊ณ ํ๋จํ์ต๋๋ค. | ||
|
|
||
| ํ์ง๋ง ํ๋ก์ ํธ๊ฐ ์ปค์ง ์ํฉ์ ๋๋นํด์ผ ํ๋ ๊ด์ ์์๋ ๋ ์ด์ด๋ฅผ ๋๋๋ ๊ฒ์ด ๋ง์์ง๋ ๋ชจ๋ฅธ๋ค๋ ๊ฐ๋ฑ์ด ์์์ต๋๋ค. ๋๋ฉ์ธ์ด ์์ ํ๋ก์ ํธ์์ ์ํคํ ์ฒ์ ๋ณต์ก๋๋ฅผ ๊ฒฐ์ ํ๋ ๋ฆฌ๋ทฐ์ด๋๋ง์ ํธ๋ ์ด๋ ์คํ ๊ธฐ์ค์ด ์๋ค๋ฉด ๋ฐฐ์ฐ๊ณ ์ถ์ต๋๋ค. | ||
| ### ์ฃผ์ 4 - ํฅํ ํ์ต ๋ฐฉํฅ์ฑ ๋ฐ ๋ง์ธ๋ ์ | ||
| ์ด๋ฒ ํ์ด ํ๋ก๊ทธ๋๋ฐ์ ์งํํ๋ฉฐ ์ ์ค์ค๋ก์ ๋ถ์กฑํจ์ ๋ง์ด ํต๊ฐํ์ต๋๋ค. ๋ค๋ฅธ ํ๋ค์ ๋์์ธ ํจํด์ ์ ๊ทน์ ์ผ๋ก ๋์ ํ๊ณ ๋ ผ์ํ๋๋ฐ, ์ ๋ ๊ทธ ๋ํ์ ์จ์ ํ ์ฐธ์ฌํ์ง ๋ชปํ๊ฑฐ๋ ํจํด์ ์ฝ๋์ ๋ น์ฌ๋ด๋ ๋ฐ ์ด๋ ค์์ ๊ฒช์์ต๋๋ค. ์ฌ์ง์ด๋ ๋น์ฆ๋์ค ๋ก์ง์ ์ง์คํ๋ค ๋ณด๋ ๊ฐ๋ ๊ฐ์ฅ ๊ธฐ๋ณธ์ ์ธ ์ธ์ด ๋ฌธ๋ฒ์กฐ์ฐจ ํท๊ฐ๋ ค ๋นํฉ์ค๋ฌ์ด ์๊ฐ๋ค๋ ์์์ต๋๋ค. | ||
|
|
||
| ๊ฐ์ฒด์งํฅ์ ์ธ ์ค๊ณ๋์ปค๋ ์ง์์ ํํธํ๋ก ์ธํด ๊ณณ๊ณณ์ ๋นํ์ด ์๋ค๋ ๋๋์ ๋ง์ด ๋ฐ์์ต๋๋ค. ๋ฆฌ๋ทฐ์ด๋์ด ๋ณด์๊ธฐ์ ํ์ฌ ์ ์์ค์์ ์ด๋ค ๋ถ๋ถ์ ๊ฐ์ฅ ์ฐ์ ์์์ ๋๊ณ ํ์ตํด์ผ ํ ๊น์? ๋จ์ํ ํจํด์ ์ธ์ฐ๋ ๊ฒ๋ณด๋ค, ์ ๊ฐ ๋์น๊ณ ์๋ ๊ธฐ๋ณธ๊ธฐ๊ฐ ๋ฌด์์ธ์ง ๋ฆฌ๋ทฐ์ด๋์ ์์ ์์ ๋์ฒ ํ๊ฒ ์ง์ด์ฃผ์๊ณ ์์ผ๋ก์ ๊ณต๋ถ ๋ฐฉํฅ์ ์ ์ํด ์ฃผ์ค ์ ์๋ค๋ฉด ์ ๋ง ๊ฐ์ฌํ๊ฒ ์ต๋๋ค. | ||
| ## โ ๊ฒ์ ๊ธฐ๋ฅ TO-DO | ||
|
|
||
| ### ๊ฒ์์ ์ฐธ์ฌํ ์ฌ๋์ ์ด๋ฆ ์ ๋ ฅ | ||
| --- | ||
|
|
||
| - [x] ์ผํ ๊ธฐ์ค์ผ๋ก ๋ถ๋ฆฌ | ||
| - [x] ์ ์์ ์ธ ์ด๋ฆ ์๋ค์ ๊ณต๋ฐฑ ์ ๊ฑฐ | ||
| - [x] `ใ ใ , ,ใ ใ ` โ ๋น ๋ฌธ์์ด์ ์์ธ์ฒ๋ฆฌ | ||
| ## ๋ฒ ํ ๊ธฐ๋ฅ TO-DO | ||
|
|
||
| ### ๊ฐ ํ๋ ์ด์ด, ๋๋ฌ์๊ฒ ์นด๋๋ฅผ ๋๋ค์ผ๋ก 2์ฅ ๋ฐฐ๋ถํ๋ ๊ธฐ๋ฅ | ||
| ### ๋ฒ ํ ๊ธ์ก ์ ๋ ฅ | ||
|
|
||
| - [x] ๋๋ฌ๋ 2๋ฒ์งธ ์นด๋๋ ์ถ๋ ฅํ์ง ์์ | ||
| - [x] ์ด๋ฏธ ์ ํด์ง ๋ฑ์์ ๋๋ค ๋ถ๋ฐฐ | ||
| - [x] ๊ฐ ํ๋ ์ด์ด์ ๋ฒ ํ ๊ธ์ก์ ์ ๋ ฅ๋ฐ๋ ๊ธฐ๋ฅ | ||
| - [x] ๋ฒ ํ ๊ธ์ก ๊ฒ์ฆ (์์๋ง ํ์ฉ) | ||
| - [x] `BettingMoney` ๊ฐ ๊ฐ์ฒด ์์ฑ | ||
|
|
||
| ### ํ๋ ์ด์ด์๊ฒ ์นด๋๋ฅผ ๋ ๋ฐ์์ง ๋ฌป๋ ๊ธฐ๋ฅ | ||
| ### ๋ธ๋์ญ ํ๋ณ | ||
|
|
||
| - [x] ์ด๋ฏธ ๋ฝํ ์นด๋๋ ๋ค์ ๋์ค์ง ์๊ฒ ์ฒ๋ฆฌ | ||
| - [x] ํ ํ๋ ์ด์ด๊ฐ n์ ์ ๋ ฅํ๋ฉด ํด๋น ํ๋ ์ด์ด ์ข ๋ฃ | ||
| - [x] `CardBundle`์ `isBlackjack()` ์ถ๊ฐ (์นด๋ 2์ฅ && ์ ์ 21) | ||
| - [x] `CardBundle`์ `isBust()` ์ถ๊ฐ (์ ์ > 21) | ||
| - [x] `Participant`์ ์์ ๋ฉ์๋ ์ถ๊ฐ | ||
|
|
||
| ### ๋๋ฌ๊ฐ ์นด๋๋ฅผ ๋ ๋ฐ๋์ง ์ถ๋ ฅ | ||
| ### ์นํจ ํ์ ๊ฐ์ | ||
|
|
||
| - [x] 16 ์ดํ๋ผ ํ ์ฅ ๋ฐ์ ๋๋ง๋ค ๋ฌธ์ฅ ์ถ๋ ฅ | ||
| - [x] ์ฌ๋ฌ ์ฅ ๋ฐ์ ๊ฒฝ์ฐ ํ ์ฅ์ฉ ๋ฌธ์ฅ ๋ฐ๋ณต ์ถ๋ ฅ | ||
| - [x] ์ฒ์๋ถํฐ 17 ์ด์์ด๋ฉด ์นด๋ ์ถ๊ฐ ์์ด ์๋ด ๋ฌธ์ฅ ์ถ๋ ฅ ์ฌ๋ถ ๊ฒฐ์ | ||
| - [x] `Outcome`์ `BLACKJACK_WIN` ์ถ๊ฐ ๋ฐ ๋ฐฐ์จ(profitRate) ํ๋ ๋์ | ||
| - [x] `BlackjackRule` ๋ธ๋์ญ ํ์ ๋ก์ง ์ถ๊ฐ | ||
| - [x] ํ๋ ์ด์ด ๋ธ๋์ญ + ๋๋ฌ ๋ธ๋์ญ โ ๋ฌด์น๋ถ | ||
| - [x] ํ๋ ์ด์ด ๋ธ๋์ญ + ๋๋ฌ ์ผ๋ฐ โ ๋ธ๋์ญ ์น๋ฆฌ (1.5๋ฐฐ) | ||
| - [x] ๋๋ฌ๋ง ๋ธ๋์ญ โ ํ๋ ์ด์ด ํจ๋ฐฐ | ||
| - [x] ๋๋ฌ ๋ฒ์คํธ โ ๋จ์์๋ ํ๋ ์ด์ด ์น๋ฆฌ | ||
|
|
||
| ### ์นด๋ ๊ฐ์ฒด ์ค๊ณ | ||
| ### ์์ต ๊ณ์ฐ | ||
|
|
||
| - [x] ์ ์ฒด ์นด๋ ๋ฑ์ ๋ฏธ๋ฆฌ ์์ฑ | ||
| - [x] deck์ ๋๋ค ์ถ์ถ ๊ธฐ๋ฅ์ผ๋ก ๊ตฌํ | ||
| - [x] suit, rank๋ฅผ ๊ฐ๊ฐ Enum์ผ๋ก ๊ด๋ฆฌ | ||
| - [x] ์นด๋ ๋ฌธ์, ํ๊ธฐ ์ ์ ๊ด๋ฆฌ ๋ฐฉ์ ๊ฒฐ์ | ||
| - [x] `BettingMoney`์ `calculateProfit(Outcome)` ๊ตฌํ (๊ธ์ก ร ๋ฐฐ์จ) | ||
| - [x] ๋๋ฌ ์์ต ๊ณ์ฐ (ํ๋ ์ด์ด ์์ต ํฉ์ฐ์ ๋ถํธ ๋ฐ์ ) โ `ProfitResult` | ||
|
|
||
| ### ์นด๋ ์ ์ ํฉ ๊ณ์ฐ ๊ธฐ๋ฅ | ||
| ### Player์ ๋ฒ ํ ์ฐ๊ฒฐ | ||
|
|
||
| - [x] rank ๊ฐ๋ง ์ถ์ถํ์ฌ ํฉ์ฐ | ||
| - [x] ์ดํฉ ๊ณ์ฐ ๋ก์ง ๊ตฌํ | ||
| - [x] `Player`์ `BettingMoney` ํ๋ ์ถ๊ฐ | ||
| - [x] `Players` ์์ฑ ๋ฐฉ์ ๋ณ๊ฒฝ (์ด๋ฆ + ๊ธ์ก) | ||
|
|
||
| ### ๊ฒฐ๊ณผ ์ถ๋ ฅ | ||
| ### ์ ์ถ๋ ฅ ์์ | ||
|
|
||
| - [x] ๋๋ฌ๊ฐ ๊ฐ์ง ์นด๋ ๋ชฉ๋ก ์ถ๋ ฅ | ||
| - [x] ๋๋ฌ ์นด๋ ์ ์ ํฉ ์ถ๋ ฅ | ||
| - [x] ํ๋ ์ด์ด๊ฐ ๊ฐ์ง ์นด๋ ๋ชฉ๋ก ์ถ๋ ฅ | ||
| - [x] ํ๋ ์ด์ด ์นด๋ ์ ์ ํฉ ์ถ๋ ฅ | ||
| - [x] `InputView`์ ๋ฒ ํ ๊ธ์ก ์ ๋ ฅ ๋ฉ์๋ ์ถ๊ฐ | ||
| - [x] `OutputView` ์ต์ข ๊ฒฐ๊ณผ๋ฅผ ๊ธ์ก์ผ๋ก ์ถ๋ ฅํ๋๋ก ๋ณ๊ฒฝ | ||
| - [x] `BlackjackController`์ ๋ฒ ํ ์ ๋ ฅ ๋จ๊ณ ๋ฐ ์์ต ์ถ๋ ฅ ๋จ๊ณ ์ถ๊ฐ | ||
|
|
||
| ### ์นํจ ์ถ๋ ฅ | ||
| ### ํ ์คํธ | ||
|
|
||
| - [x] ๊ณ์ฐ๋ ํฉ์ ๋ฐ๋ผ ์นํจ ํ๋ณ | ||
| - [x] `BettingMoney` ๊ฒ์ฆ ํ ์คํธ (์์, 0, ์์) | ||
| - [x] `CardBundle` ๋ธ๋์ญ/๋ฒ์คํธ ํ๋ณ ํ ์คํธ | ||
| - [x] `BlackjackRule` ๋ธ๋์ญ ์ผ์ด์ค ํ์ ํ ์คํธ (8๊ฐ ์ผ์ด์ค) | ||
| - [x] ์์ต ๊ณ์ฐ ํ ์คํธ (๋ธ๋์ญ ์น๋ฆฌ, ์ผ๋ฐ ์น๋ฆฌ, ๋ฌด์น๋ถ, ํจ๋ฐฐ) | ||
| - [x] `ProfitResult` ๋๋ฌ ์์ต ์ง๊ณ ํ ์คํธ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,12 @@ | ||
| package controller; | ||
|
|
||
| import domain.Dealer; | ||
| import domain.Deck; | ||
| import domain.Player; | ||
| import domain.Players; | ||
| import domain.Referee; | ||
| import domain.Result; | ||
| import domain.participant.Dealer; | ||
| import domain.card.Deck; | ||
| import domain.participant.Player; | ||
| import domain.participant.Players; | ||
| import domain.game.BlackjackRule; | ||
| import domain.game.Outcome; | ||
| import domain.game.ProfitResult; | ||
| import java.util.LinkedHashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
@@ -24,28 +25,32 @@ public BlackjackController(InputView inputView, OutputView outputView) { | |
|
|
||
| public void run() { | ||
| List<String> names = inputView.inputPlayers(); | ||
| Players players = new Players(names); | ||
| Players players = new Players(inputBets(names)); | ||
| Dealer dealer = new Dealer("๋๋ฌ"); | ||
| Deck deck = new Deck(); | ||
| dealInitialCards(dealer, players, deck); | ||
| dealInitialCards(dealer, players, deck); | ||
| dealInitialTwoCards(dealer, players, deck); | ||
| printInitialState(dealer, players, names); | ||
| playAllPlayerTurns(players, deck); | ||
| playDealerTurn(dealer, deck); | ||
| printFinalState(dealer, players); | ||
| printFinalCards(dealer, players); | ||
| printProfitResult(dealer, players); | ||
| } | ||
|
|
||
| private void playAllPlayerTurns(Players players, Deck deck) { | ||
| for (Player player : players.getGamePlayers()) { | ||
| playPlayerTurn(player, deck); | ||
| private Map<String, Integer> inputBets(List<String> names) { | ||
| Map<String, Integer> nameToBet = new LinkedHashMap<>(); | ||
| for (String name : names) { | ||
| nameToBet.put(name, inputView.inputBettingAmount(name)); | ||
| } | ||
| return nameToBet; | ||
| } | ||
|
|
||
| private void dealInitialCards(Dealer dealer, Players players, Deck deck) { | ||
| for (Player player : players.getGamePlayers()) { | ||
| player.addCard(deck.draw()); | ||
| private void dealInitialTwoCards(Dealer dealer, Players players, Deck deck) { | ||
| for (int i = 0; i < 2; i++) { | ||
|
Member
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.
|
||
| for (Player player : players.getGamePlayers()) { | ||
| player.addCard(deck.draw()); | ||
| } | ||
| dealer.addCard(deck.draw()); | ||
| } | ||
| dealer.addCard(deck.draw()); | ||
| } | ||
|
|
||
| private void printInitialState(Dealer dealer, Players players, List<String> names) { | ||
|
|
@@ -54,7 +59,13 @@ private void printInitialState(Dealer dealer, Players players, List<String> name | |
| for (Player player : players.getGamePlayers()) { | ||
| outputView.printPlayerCards(player); | ||
| } | ||
| System.out.println(); | ||
| outputView.printNewLine(); | ||
| } | ||
|
|
||
| private void playAllPlayerTurns(Players players, Deck deck) { | ||
| for (Player player : players.getGamePlayers()) { | ||
| playPlayerTurn(player, deck); | ||
| } | ||
| } | ||
|
|
||
| private void playPlayerTurn(Player player, Deck deck) { | ||
|
|
@@ -71,17 +82,26 @@ private void playDealerTurn(Dealer dealer, Deck deck) { | |
| } | ||
| } | ||
|
|
||
| private void printFinalState(Dealer dealer, Players players) { | ||
| System.out.println(); | ||
| private void printFinalCards(Dealer dealer, Players players) { | ||
| outputView.printNewLine(); | ||
| outputView.printFinalCards(dealer); | ||
| for (Player player : players.getGamePlayers()) { | ||
| outputView.printFinalCards(player); | ||
| } | ||
| Referee referee = new Referee(); | ||
| Map<Player, Result> results = new LinkedHashMap<>(); | ||
| } | ||
|
|
||
| private ProfitResult calculateProfits(Dealer dealer, Players players) { | ||
| BlackjackRule rule = new BlackjackRule(); | ||
| Map<Player, Integer> playerProfits = new LinkedHashMap<>(); | ||
| for (Player player : players.getGamePlayers()) { | ||
| results.put(player, referee.judge(player.getScore(), dealer.getScore())); | ||
| Outcome outcome = rule.judge(player, dealer); | ||
| playerProfits.put(player, player.calculateProfit(outcome)); | ||
| } | ||
| outputView.printFinalResult(dealer, results); | ||
| return new ProfitResult(playerProfits); | ||
| } | ||
|
|
||
| private void printProfitResult(Dealer dealer, Players players) { | ||
| ProfitResult profitResult = calculateProfits(dealer, players); | ||
| outputView.printProfitResult(dealer.getName(), profitResult); | ||
| } | ||
| } | ||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package domain; | ||
| package domain.card; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package domain; | ||
| package domain.card; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
@@ -13,21 +13,32 @@ public CardBundle() { | |
| } | ||
|
|
||
| public int calculateScore() { | ||
| int score = 0; | ||
| boolean hasAce = false; | ||
| int basicScore = calculateBasicScore(); | ||
| boolean hasAce = hasAce(); | ||
|
|
||
| return applyAceBonus(basicScore, hasAce); | ||
| } | ||
|
|
||
| private int calculateBasicScore() { | ||
| int score = 0; | ||
| for (Card card : cards) { | ||
| score += card.getScore(); | ||
| } | ||
| return score; | ||
| } | ||
|
|
||
| private boolean hasAce() { | ||
| for (Card card : cards) { | ||
| if (card.isAce()) { | ||
| hasAce = true; | ||
| return true; | ||
| } | ||
| } | ||
| return applyAceBonus(score, hasAce); | ||
| return false; | ||
| } | ||
|
Comment on lines
+22
to
37
Member
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. Stream์ |
||
|
|
||
| private int applyAceBonus(int score, boolean hasAce) { | ||
| if (isSoftHand(score, hasAce)) { | ||
| return score + 10; | ||
| return score + ACE_BONUS; | ||
| } | ||
| return score; | ||
| } | ||
|
|
@@ -40,7 +51,15 @@ public void addCard(Card card) { | |
| cards.add(card); | ||
| } | ||
|
|
||
| public boolean isBlackjack() { | ||
| return cards.size() == 2 && calculateScore() == BUST_THRESHOLD; | ||
| } | ||
|
|
||
| public boolean isBust() { | ||
| return calculateScore() > BUST_THRESHOLD; | ||
| } | ||
|
|
||
| public List<Card> getCards() { | ||
| return cards; | ||
| return List.copyOf(cards); | ||
| } | ||
| } | ||
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.
์ข์ ์ ๊ทผ์ด๋ค์.
Tell, Don't Ask๋ผ๋ ์ด์ผ๊ธฐ๋ ๊ฒฐ๊ตญ์๋ ์ฌ๋ฌ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด ๋์๋ค๊ณ ์๊ฐํด์. ๋ณ๊ฒฝ๋๋ ๊ฒ๊ณผ ๊ทธ๋ ์ง ์์ ๊ฒ, ๋ณ๊ฒฝ๋๋ค๊ณ ํ๋ฉด ๊ทธ ์ ํ๋ฅผ ์ต์ํํ๋ ๋ฐฉํฅ์ ๊พธ์คํ ๊ณ ๋ฏผํด๋ณด์๋ ๊ฒ ์ข์ต๋๋ค! ์ด๋ ๋ ์ค์ํ ๊ฑด ๋ค๋ฅธ ํ์๋ค์๊ฒ ๋์ ์ฃผ์ฅ์ ์ ์ค๋ํ๋ ๋ฐฉ๋ฒ์ด๊ฒ ๋ค์.