Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
11 commits
Select commit Hold shift + click to select a range
87aee51
chore: dto ๋‚ด๋ถ€ ํŒจํ‚ค์ง€ ์ƒ์„ฑ ๋ฐ class ๋ถ„๋ฆฌ
choiyoung69 Mar 12, 2026
393a2d2
docs: readme.md์— ๊ธฐ๋Šฅ๋ชฉ๋ก ์ •๋ฆฌ
choiyoung69 Mar 12, 2026
522d292
feat: ๋ฒ ํŒ… ๊ธˆ์•ก ๊ฒ€์ฆ
choiyoung69 Mar 12, 2026
5693e1b
feat: ๊ธˆ์•ก ๋ฐ›์•„์˜ค๋Š” dto ์ƒ์„ฑ
choiyoung69 Mar 12, 2026
680e615
test: ๊ฒœ๋ธ”๋Ÿฌ์˜ ๋ฒ ํŒ… ๊ธˆ์•ก ๊ฒ€์ฆ ํ…Œ์ŠคํŠธ ์ถ”๊ฐ€
choiyoung69 Mar 12, 2026
32eeef4
feat: ๋ฒ ํŒ… ๊ธˆ์•ก์„ gambler๊ฐ€ ๊ฐ€์ง€๋„๋ก ๊ธฐ๋Šฅ ์ถ”๊ฐ€
choiyoung69 Mar 13, 2026
5a63634
feat: ๊ธˆ์•ก์„ string -> integer๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ๊ฒ€์ฆ ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€
choiyoung69 Mar 13, 2026
8f1e0eb
refactor: ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•  ๋•Œ ๋‹ค๋ฅธ ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•˜์ง€ ์•Š๊ณ  ์™ธ๋ถ€์—์„œ ์ฃผ์ž…๋ฐ›๋„๋ก ์ˆ˜์ •
choiyoung69 Mar 13, 2026
e204224
refactor: ์ถœ๋ ฅ ํ˜•์‹ ๊ธˆ์•ก์œผ๋กœ ์ˆ˜์ •
choiyoung69 Mar 14, 2026
bb050ef
docs: Readme.md ์ˆ˜์ •
choiyoung69 Mar 14, 2026
5b79b75
feat: 1000์› ๋‹จ์œ„ ๊ฒ€์ฆ ์ถ”๊ฐ€
choiyoung69 Mar 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 37 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,54 @@
## ๋ธ”๋ž™์žญ ๋ฏธ์…˜ ๊ธฐ๋Šฅ ๋ช…์„ธ

### ์ž…๋ ฅ
- [x] "๊ฒŒ์ž„์— ์ฐธ์—ฌํ•  ์‚ฌ๋žŒ์˜ ์ด๋ฆ„์„ ์ž…๋ ฅํ•˜์„ธ์š”.(์‰ผํ‘œ ๊ธฐ์ค€์œผ๋กœ ๋ถ„๋ฆฌ) " ๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.
- [x] ๊ฒŒ์ž„์— ์ฐธ์—ฌํ•˜๋Š” ์ฐธ๊ฐ€์ž์˜ ์ด๋ฆ„์„ ์‰ผํ‘œ ๊ธฐ์ค€์œผ๋กœ ๋‚˜๋ˆ„๋Š” ๋ฌธ์ž์—ด์„ ํ•˜๋‚˜ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค.
- [x] ์ฐธ๊ฐ€์ž๋“ค์—๊ฒŒ ๊ฐ๊ฐ ๋ฒ ํŒ… ๊ธˆ์•ก์„ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค.
- [x] ๊ฒŒ์ž„์„ ๊ณ„์† ์ง„ํ–‰ํ•  ์ง€ ๊ฒฐ์ •ํ•˜๋Š” (y/n) ๋Š” y, n๋ฅผ ์ž…๋ ฅํ•œ๋‹ค.

### ์ž…๋ ฅ ์˜ˆ์™ธ

- [x] ์ด๋ฆ„์€ ์‰ผํ‘œ ๊ธฐ์ค€์œผ๋กœ ๋ถ„๋ฆฌ๋˜์–ด 1๊ฐœ ์ด์ƒ์ด์–ด์•ผ ํ•œ๋‹ค.
- [x] ์ด๋ฆ„์€ ์˜์–ด๋กœ 2~10์ž ์‚ฌ์ด์—ฌ์•ผ ํ•œ๋‹ค.
- [x] ์ด๋ฆ„์€ ์˜์–ด๋กœ๋งŒ ์—Š๋ฃจ์ดํ•œ์•ผ ์ ธ์–ด๋ฃจ๋‹คํ•œ์•ผ.
- [x] ์ด๋ฆ„์€ ์†Œ๋ฌธ์ž ๊ธฐ์ค€์œผ๋กœ ์ค‘๋ณต๋˜์ง€ ์•Š๋Š”๋‹ค.
- [x] ๊ฒŒ์ž„์„ ๊ณ„์† ์ง„ํ–‰ํ•  ์ง€ ๊ฒฐ์ •ํ•˜๋Š” y, n๋งŒ ์ž…๋ ฅํ•  ์ˆ˜ ์žˆ๋‹ค.

### ๊ธฐ๋Šฅ

1. ์ž…๋ ฅ ์ฒ˜๋ฆฌ

- [x] ์ž…๋ ฅ๋ฐ›์€ ๋ฌธ์ž์—ด์„ โ€˜,โ€™๋ฅผ ๊ธฐ์ค€์œผ๋กœ ํŒŒ์‹ฑํ•œ๋‹ค.
- [x] ํŒŒ์‹ฑํ•œ ์ด๋ฆ„์„ ๊ฒ€์ฆํ•œ๋‹ค.

1. ๊ฒŒ์ž„ ์„ธํŒ…
- [x] ํ•œ ๋ช…์˜ ๋”œ๋Ÿฌ๊ฐ€ ์กด์žฌํ•œ๋‹ค.
- [x] ๋”œ๋Ÿฌ๋Š” "Dealer"๋ผ๋Š” ์ด๋ฆ„์œผ๋กœ ๊ณ ์ •๋œ๋‹ค.

- [x] ์—ฌ๋Ÿฌ ๋ช…์˜ ์ฐธ๊ฐ€์ž๊ฐ€ ์กด์žฌํ•œ๋‹ค.
- [x] ์ฐธ๊ฐ€์ž๋Š” ์ตœ์†Œ 1๋ช… ์ด์ƒ์ด๋‹ค.
- [x] ์ฐธ๊ฐ€์ž๋Š” ์ด๋ฆ„์„ ๊ฐ€์ง„๋‹ค.
- [x] ์ด๋ฆ„์€ 2 ~ 10์ž ์‚ฌ์ด์ด๋‹ค.
- [x] ์ด๋ฆ„์€ ์•ŒํŒŒ๋ฒณ์œผ๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ๋‹ค.
- [x] ์ฐธ๊ฐ€์ž๋Š” ๋ฒ ํŒ… ๊ธˆ์•ก์„ ๊ฐ–๋Š”๋‹ค.
- [x] ์ž…๋ ฅ ๊ธˆ์•ก์€ ์–‘์ˆ˜์—ฌ์•ผ ํ•œ๋‹ค.
- [x] ์ž…๋ ฅ ๊ธˆ์•ก์€ 100์–ต์„ ๋„˜์ง€ ์•Š๋Š”๋‹ค.
- [x] ์ฐธ๊ฐ€์ž๋“ค์˜ ์ด๋ฆ„์€ ์ค‘๋ณต์ผ ์ˆ˜ ์—†๋‹ค

2. ๊ฒŒ์ž„ ์ง„ํ–‰

- [x] ๋”œ๋Ÿฌ์™€ ์ฐธ๊ฐ€์ž๋“ค์—๊ฒŒ ๊ฐ๊ฐ 2 ์žฅ์˜ ์นด๋“œ๋ฅผ ๋žœ๋คํ•˜๊ฒŒ ๋ถ€์—ฌํ•œ๋‹ค. ์ด๋•Œ ๋”œ๋Ÿฌ์˜ ์นด๋“œ๋Š” ๊ฐ€์žฅ ์ฒ˜์Œ ๋ฐ›์€ ์นด๋“œ ํ•œ ์žฅ๋งŒ ๋ณด์—ฌ์ค€๋‹ค.
- [x] ๊ฐ ์ฐธ๊ฐ€์ž๋“ค๋ณ„๋กœ bust๊ฐ€ ๋‚˜๊ธฐ ์ „๊นŒ์ง€ ์นด๋“œ๋ฅผ ๋” ๋ฐ›๋Š” Hit(y) ๋˜๋Š” ๊ทธ๋งŒ ๋ฐ›๋Š” Stand(n)๋ฅผ ์„ ํƒํ•œ๋‹ค.
- [x] โ€˜A์—์ด์Šคโ€™๋Š” ํ˜„์žฌ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ์นด๋“œ์˜ ํ•ฉ์— ๋”ฐ๋ผ ์ž๋™์œผ๋กœ ๊ณ„์‚ฐ๋˜์–ด ์ ์šฉ๋œ๋‹ค.
- [x] ํ˜„์žฌ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ์นด๋“œ์˜ ํ•ฉ + 11์˜ ๊ฐ’์ด 21 ์ดˆ๊ณผ์ธ ๊ฒฝ์šฐ 1๋กœ ๊ณ„์‚ฐํ•œ๋‹ค.
- [x] ํ˜„์žฌ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ์นด๋“œ์˜ ํ•ฉ + 11์˜ ๊ฐ’์ด 21์ธ ๊ฒฝ์šฐ 11๋กœ ๊ณ„์‚ฐํ•œ๋‹ค.
- [x] ํ˜„์žฌ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ์นด๋“œ์˜ ํ•ฉ + 11์˜ ๊ฐ’์ด 21 ๋ฏธ๋งŒ์ด๋ฉด 11๋กœ ๊ณ„์‚ฐํ•œ๋‹ค.
- [x] ๋”œ๋Ÿฌ๊ฐ€ ์ฒ˜์Œ ๋ฐ›์€ 2์žฅ์˜ ํ•ฉ๊ณ„๊ฐ€ 16์ดํ•˜๋ฉด ๋ฐ˜๋“œ์‹œ 1์žฅ์˜ ์นด๋“œ๋ฅผ ์ถ”๊ฐ€๋กœ ๋ฐ›์•„์•ผ ํ•˜๊ณ , 17์  ์ด์ƒ์ด๋ฉด ์ถ”๊ฐ€๋กœ ๋ฐ›์„ ์ˆ˜ ์—†๋‹ค. (1์žฅ ์ดˆ๊ณผ ๋ฐ›์ง€ ์•Š์Œ)



3. ๊ฒฐ๊ณผ ์ฒ˜๋ฆฌ

- [X] ๋ฑ์€ ํ•œ ๋ฑ(52์žฅ)์œผ๋กœ ๊ณ ์ •ํ•œ๋‹ค(์ด๋•Œ ํ•˜๋“œ์ฝ”๋”ฉํ•˜์ง€ ์•Š๋Š”๋‹ค)
- [x] ๋”œ๋Ÿฌ์™€ ์ฐธ๊ฐ€์ž๋Š” ์†ํŒจ(์นด๋“œ ๋ชฉ๋ก)์„ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋‹ค.
- [x] ์นด๋“œ๋Š” ๋žœ๋คํ•˜๊ฒŒ ๋ถ€์—ฌ๋œ๋‹ค.
- [x] ๋”œ๋Ÿฌ์™€ ์ฐธ๊ฐ€์ž๋Š” ๊ฒŒ์ž„ ์‹œ์ž‘ ์‹œ 2์žฅ์˜ ์นด๋“œ๋ฅผ ๋ถ€์—ฌ๋ฐ›๋Š”๋‹ค.
- [x] ๋ฑ์€ ํ•œ ๋ฑ(52์žฅ)์œผ๋กœ ๊ณ ์ •ํ•œ๋‹ค
- [x] ์นด๋“œ๋Š” ์ ์ˆ˜๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค.
- [x] ์ˆซ์ž ์นด๋“œ๋Š” ์ˆซ์ž๋งŒํผ์˜ ์ ์ˆ˜๋ฅผ ๊ฐ€์ง„๋‹ค.
- [x] ACE์ธ ๊ฒฝ์šฐ 1 ๋˜๋Š” 11์˜ ๊ฐ’์„ ๊ฐ€์ง„๋‹ค
- [x] K, Q, J๋Š” 10์ ์„ ๊ฐ€์ง„๋‹ค.
- [x] ์ฐธ๊ฐ€์ž๋“ค์€ ๋ฒ„์ŠคํŠธ๋‚˜๊ธฐ ์ „๊นŒ์ง€ ์นด๋“œ๋ฅผ ๋” ๋ฐ›๋Š” Hit(y)ํ•  ์ˆ˜ ์žˆ๋‹ค.
- [x] ์ฐธ๊ฐ€์ž๋“ค์€ ์นด๋“œ๋ฅผ ๊ทธ๋งŒ ๋ฐ›๋Š” Stand(n)๋ฅผ ์„ ํƒํ•  ์ˆ˜ ์žˆ๋‹ค.
- [x] y/n ์ด์™ธ์˜ ์ž…๋ ฅ์€ ๋ฐ›์„ ์ˆ˜ ์—†๋‹ค
- [x] ๋”œ๋Ÿฌ๋Š” ์ฒ˜์Œ 2์žฅ์˜ ํ•ฉ์ด 16์ดํ•˜๋ฉด 1์žฅ์˜ ์นด๋“œ๋ฅผ ์ถ”๊ฐ€๋กœ ๋ฐ›๋Š”๋‹ค.

3. ๊ฒŒ์ž„ ์ ์ˆ˜ ๊ณ„์‚ฐ
- [x] ๋”œ๋Ÿฌ์™€ ๊ฐ ์ฐธ๊ฐ€์ž๋“ค์˜ ์นด๋“œ ํ•ฉ์„ ๊ตฌํ•œ๋‹ค.
- [x] ACE๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š์„ ๊ฒฝ์šฐ ๋ชจ๋“  ์นด๋“œ ์ ์ˆ˜๋ฅผ ํ•ฉ์‚ฐํ•œ๋‹ค.
- [x] ACE๊ฐ€ ์กด์žฌํ•  ๊ฒฝ์šฐ 11๋กœ ์ง€์ •ํ•œ ๋’ค ํ•ฉ์‚ฐํ•œ ์นด๋“œ ์ ์ˆ˜๊ฐ€ 21์„ ์ด์ƒ์ธ ๊ฒฝ์šฐ 1๋กœ ํ™˜์‚ฐํ•˜์—ฌ ๊ณ„์‚ฐํ•œ๋‹ค

4. ๊ฒŒ์ž„ ๊ฒฐ๊ณผ
- [x] ์ฐธ๊ฐ€์ž ์Šน : ๋”œ๋Ÿฌ๋ณด๋‹ค ํ•ฉ์ด 21์— ๋” ๊ฐ€๊นŒ์šด ๊ฒฝ์šฐ or ๋”œ๋Ÿฌ๊ฐ€ ๋ฒ„์ŠคํŠธ์ธ ๊ฒฝ์šฐ(์ฐธ๊ฐ€์ž ๋ฒ„์ŠคํŠธ X)
- [x] ์ฐธ๊ฐ€์ž ๋ฌด์Šน๋ถ€: ์ฐธ๊ฐ€์ž์™€ ๋”œ๋Ÿฌ์˜ ํ•ฉ์ด ๊ฐ™์Œ(๋ฒ„์ŠคํŠธ X)
- [x] ์ฐธ๊ฐ€์ž๊ฐ€ 21์ธ ๊ฒฝ์šฐ : ๋ฒ ํŒ… ๊ธˆ์•ก์˜ 1.5๋ฐฐ๋ฅผ ๋ฐ›๋Š”๋‹ค
- [x] ์ฐธ๊ฐ€์ž๊ฐ€ 21์ด ์•„๋‹Œ ๊ฒฝ์šฐ : ๋ฒ ํŒ… ๊ธˆ์•ก๋งŒํผ ๋ฐ›๋Š”๋‹ค
- [x] ์ฐธ๊ฐ€์ž ๋ฌด์Šน๋ถ€: ์ฐธ๊ฐ€์ž์™€ ๋”œ๋Ÿฌ์˜ ํ•ฉ์ด ๊ฐ™์Œ
- [x] ๊ธฐ์กด ๋ฒ ํŒ… ๊ธˆ์•ก์„ ๊ทธ๋Œ€๋กœ ๋Œ๋ ค๋ฐ›๋Š”๋‹ค.
- [x] ์ฐธ๊ฐ€์ž ํŒจ : ์ฐธ๊ฐ€์ž ๋ฒ„์ŠคํŠธ or ๋”œ๋Ÿฌ๋ณด๋‹ค ํ•ฉ์ด ์ ์Œ(๋”œ๋Ÿฌ๊ฐ€ ๋ฒ„์ŠคํŠธ X)
- [x] ๋ฒ ํŒ… ๊ธˆ์•ก์„ ์žƒ๋Š”๋‹ค.
Comment on lines 10 to +51
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์š”๊ตฌ์‚ฌํ•ญ์„ ๊ผผ๊ผผํ•˜๊ฒŒ ์ž˜ ์ •๋ฆฌํ•˜์˜€๋„ค์š” ๐Ÿ‘


### ์ถœ๋ ฅ

- [x] ์ฐธ๊ฐ€์ž๋ฅผ ์ž…๋ ฅ๋ฐ›์€ ํ›„ โ€œ๋”œ๋Ÿฌ์™€ [์ฐธ๊ฐ€์ž ๋ชฉ๋ก]์—๊ฒŒ 2์žฅ์„ ๋‚˜๋ˆ„์—ˆ์Šต๋‹ˆ๋‹ค. โ€ ๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. ์ด๋•Œ ์ฐธ๊ฐ€์ž์˜ ์ด๋ฆ„์€ ์‰ผํ‘œ๋กœ ๊ตฌ๋ถ„ํ•˜์—ฌ ์ถœ๋ ฅํ•œ๋‹ค.
- [x] ๋”œ๋Ÿฌ์™€ ์ฐธ๊ฐ€์ž๋“ค์˜ ์นด๋“œ๋ฅผ ๊ฐ๊ฐ ์‰ผํ‘œ๋กœ ๊ตฌ๋ถ„ํ•˜์—ฌ ์ถœ๋ ฅํ•œ๋‹ค.
- [x] ๊ฐ ์ฐธ๊ฐ€์ž์˜ ๊ฒŒ์ž„ ํ„ด์— โ€œ[์ฐธ๊ฐ€์ž]๋Š” ํ•œ์žฅ์˜ ์นด๋“œ๋ฅผ ๋” ๋ฐ›๊ฒ ์Šต๋‹ˆ๊นŒ?(์˜ˆ๋Š” y, ์•„๋‹ˆ์˜ค๋Š” n)" ๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.
Expand Down
69 changes: 51 additions & 18 deletions src/main/java/controller/BlackJackController.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,22 @@
import static util.Constants.HIT;
import static util.Constants.STAND;

import domain.card.GameCards;
import domain.game.GamblersGameResult;
import domain.game.Game;
import domain.player.Dealer;
import domain.player.Gambler;
import dto.AgreementRequestDto;
import dto.DealerResultDto;
import dto.ParticipantHandResponseDto;
import dto.ParticipantsGameInfoDto;
import dto.ParticipantsHandResponseDto;
import domain.player.Gamblers;
import domain.player.attribute.Hand;
import domain.player.attribute.Money;
import domain.player.attribute.Name;
import dto.request.AgreementRequestDto;
import dto.response.DealerResultDto;
import dto.response.ParticipantHandResponseDto;
import dto.response.ParticipantsGameInfoDto;
import dto.response.ParticipantsHandResponseDto;
import java.util.List;
import java.util.stream.Collectors;
import util.Parser;
import view.input.InputView;
import view.output.OutputView;
Expand All @@ -28,8 +35,11 @@ public BlackJackController(InputView inputView, OutputView outputView) {
}

public void run() {
List<String> names = inputGamblersInfo();
Game game = initializeGame(names);
Dealer dealer = makeDealer();
Gamblers gamblers = makeGambers();
GameCards gambeCards = new GameCards(1);

Game game = initializeGame(dealer, gamblers, gambeCards);

playGame(game);
checkDealerHand(game);
Expand All @@ -39,24 +49,42 @@ public void run() {
determineFinalGameResult(game.getResult());
}

private void determineFinalGameResult(GamblersGameResult gamblersGameResult) {
outputView.printDealerResult(
new DealerResultDto(gamblersGameResult.countDealerWin(),
gamblersGameResult.countDealerLose(),
gamblersGameResult.countDealerDraw()));
outputView.printGamblerResult(
gamblersGameResult.getResultInfo()
);
private Dealer makeDealer() {
Name dealerName = new Name(DEALER_NAME);
Hand dealerHand = new Hand();
Dealer dealer = new Dealer(dealerName, dealerHand);

return dealer;
}

private Gamblers makeGambers() {
List<Name> names = inputGamblersInfo()
.stream()
.map(Name::new)
.toList();

List<Gambler> gamblerList = names.stream()
.map(name -> {
String betAmountInput = inputView.askGamblerBetAmount(name.getName())
.betAmount();
Hand hand = new Hand();
Money betAmount = new Money(betAmountInput);

return new Gambler(name, hand, betAmount);
})
.toList();
return new Gamblers(gamblerList);
}

private List<String> inputGamblersInfo() {
String name = inputView.askGamblerNames().name();
return Parser.parse(name, COMMA_DELIMITER);
}

private Game initializeGame(List<String> names) {
Game game = new Game(DEALER_NAME, names, 1);
private Game initializeGame(Dealer dealer, Gamblers gamblers, GameCards cards) {
Game game = new Game(dealer, gamblers, cards);

outputView.printInitialDeal(names);
outputView.printInitialDeal(gamblers.getNames());
game.initializeGame();
outputView.printParticipantsInfo(
new ParticipantsHandResponseDto(game.getInitialParticipantsHandInfo())
Expand Down Expand Up @@ -98,4 +126,9 @@ private void printParticipantsResult(Game game) {
game.getParticipantGameInfos()
));
}

private void determineFinalGameResult(GamblersGameResult gamblersGameResult) {
outputView.printDealerResult(new DealerResultDto(gamblersGameResult.getDealerResult()));
outputView.printGamblerResult(gamblersGameResult.getResultInfo());
}
}
61 changes: 25 additions & 36 deletions src/main/java/domain/game/GamblersGameResult.java
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
Copy link

Choose a reason for hiding this comment

The 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);
}
}
10 changes: 5 additions & 5 deletions src/main/java/domain/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public class Game {
private final Gamblers gamblers;
private final GameCards gameCards;

public Game(String dealerName, List<String> names, int amount) {
this.dealer = new Dealer(dealerName);
this.gamblers = new Gamblers(names);
this.gameCards = new GameCards(amount);
public Game(Dealer dealer, Gamblers gamblers, GameCards gameCards) {
this.dealer = dealer;
this.gamblers = gamblers;
this.gameCards = gameCards;
}

public void initializeGame() {
Expand Down Expand Up @@ -71,7 +71,7 @@ public List<Integer> getGamblersHandSize() {
}

public GamblersGameResult getResult(){
return new GamblersGameResult(dealer.getTotalScore(), gamblers.getParticipantTotalScore());
return new GamblersGameResult(dealer, gamblers);
}
}

6 changes: 3 additions & 3 deletions src/main/java/domain/game/GameResult.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package domain.game;

import static util.Constants.BLACK_JACK;
import static util.Constants.BLACK_JACK_NUMBER;

public enum GameResult {

Expand All @@ -15,8 +15,8 @@ public enum GameResult {
}

public static GameResult determine(int dealerScore, int gamblerScore) {
if(gamblerScore > BLACK_JACK) return LOSE;
if(dealerScore > BLACK_JACK) return WIN;
if(gamblerScore > BLACK_JACK_NUMBER) return LOSE;
if(dealerScore > BLACK_JACK_NUMBER) return WIN;

if(dealerScore < gamblerScore) {
return WIN;
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/domain/player/Dealer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

import static util.Constants.DEALER_REFERENCE_POINT;

import domain.player.attribute.Hand;
import domain.player.attribute.Name;

public class Dealer extends Participant {

public Dealer(String name) {
super(name);
public Dealer(Name name, Hand hand) {
super(name, hand);
}

public boolean isTotalScore16OrLess() {
Expand Down
16 changes: 14 additions & 2 deletions src/main/java/domain/player/Gambler.java
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;
Copy link

Choose a reason for hiding this comment

The 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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์š”๊ฑฐ ์ œ๊ฐ€ ์ด์ „ ๋ฆฌ๋ทฐ์—์„œ ๋†“์น˜๊ธด ํ–ˆ๋Š”๋ฐ ์ปจ๋ฒค์…˜ ๋งž์ถ”๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™๋„ค์š”!

}
Loading