From 2c1ca1a080c804194a1fdcd0c0cab84a048927ab Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Sun, 28 Jan 2024 13:15:32 +0900 Subject: [PATCH 01/48] =?UTF-8?q?README.md:=20=EA=B8=B0=EB=8A=A5=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=201=EC=B0=A8=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 152 +++++++++++++++++++++++++++--------------------------- 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/README.md b/README.md index 003db037..8e0bf21c 100644 --- a/README.md +++ b/README.md @@ -1,76 +1,76 @@ -# java-blackjack - -## ๐Ÿš€ ๊ธฐ๋Šฅ ์š”๊ตฌ ์‚ฌํ•ญ - -## โœ… 1๋‹จ๊ณ„ - ๋ธ”๋ž™์žญ ๊ตฌํ˜„ - -๋ธ”๋ž™์žญ ๊ฒŒ์ž„์„ ๋ณ€ํ˜•ํ•œ ํ”„๋กœ๊ทธ๋žจ์„ ๊ตฌํ˜„ํ•œ๋‹ค. ๋ธ”๋ž™์žญ ๊ฒŒ์ž„์€ ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด ์ค‘ ์นด๋“œ์˜ ํ•ฉ์ด 21 ๋˜๋Š” 21์— ๊ฐ€์žฅ ๊ฐ€๊นŒ์šด ์ˆซ์ž๋ฅผ ๊ฐ€์ง€๋Š” ์ชฝ์ด ์ด๊ธฐ๋Š” ๊ฒŒ์ž„์ด๋‹ค. - -์นด๋“œ์˜ ์ˆซ์ž ๊ณ„์‚ฐ์€ ์นด๋“œ ์ˆซ์ž๋ฅผ ๊ธฐ๋ณธ์œผ๋กœ ํ•˜๋ฉฐ, ์˜ˆ์™ธ๋กœ Ace๋Š” 1 ๋˜๋Š” 11๋กœ ๊ณ„์‚ฐํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, King, Queen, Jack์€ ๊ฐ๊ฐ 10์œผ๋กœ ๊ณ„์‚ฐํ•œ๋‹ค. -๊ฒŒ์ž„์„ ์‹œ์ž‘ํ•˜๋ฉด ํ”Œ๋ ˆ์ด์–ด๋Š” ๋‘ ์žฅ์˜ ์นด๋“œ๋ฅผ ์ง€๊ธ‰ ๋ฐ›์œผ๋ฉฐ, ๋‘ ์žฅ์˜ ์นด๋“œ ์ˆซ์ž๋ฅผ ํ•ฉ์ณ 21์„ ์ดˆ๊ณผํ•˜์ง€ ์•Š์œผ๋ฉด์„œ 21์— ๊ฐ€๊น๊ฒŒ ๋งŒ๋“ค๋ฉด ์ด๊ธด๋‹ค. 21์„ ๋„˜์ง€ ์•Š์„ ๊ฒฝ์šฐ ์›ํ•œ๋‹ค๋ฉด ์–ผ๋งˆ๋“ ์ง€ ์นด๋“œ๋ฅผ ๊ณ„์† ๋ฝ‘์„ ์ˆ˜ ์žˆ๋‹ค. -๋”œ๋Ÿฌ๋Š” ์ฒ˜์Œ์— ๋ฐ›์€ 2์žฅ์˜ ํ•ฉ๊ณ„๊ฐ€ 16์ดํ•˜์ด๋ฉด ๋ฐ˜๋“œ์‹œ 1์žฅ์˜ ์นด๋“œ๋ฅผ ์ถ”๊ฐ€๋กœ ๋ฐ›์•„์•ผ ํ•˜๊ณ , 17์  ์ด์ƒ์ด๋ฉด ์ถ”๊ฐ€๋กœ ๋ฐ›์„ ์ˆ˜ ์—†๋‹ค. -๊ฒŒ์ž„์„ ์™„๋ฃŒํ•œ ํ›„ ๊ฐ ํ”Œ๋ ˆ์ด์–ด๋ณ„๋กœ ์ŠนํŒจ๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. - -## ๐Ÿ’ป ์‹คํ–‰ ๊ฒฐ๊ณผ -``` -๊ฒŒ์ž„์— ์ฐธ์—ฌํ•  ์‚ฌ๋žŒ์˜ ์ด๋ฆ„์„ ์ž…๋ ฅํ•˜์„ธ์š”.(์‰ผํ‘œ ๊ธฐ์ค€์œผ๋กœ ๋ถ„๋ฆฌ) -pobi,jason - -๋”œ๋Ÿฌ์™€ pobi, jason์—๊ฒŒ 2์žฅ์„ ๋‚˜๋ˆ„์—ˆ์Šต๋‹ˆ๋‹ค. -๋”œ๋Ÿฌ: 3๋‹ค์ด์•„๋ชฌ๋“œ -pobi์นด๋“œ: 2ํ•˜ํŠธ, 8์ŠคํŽ˜์ด๋“œ -jason์นด๋“œ: 7ํด๋กœ๋ฒ„, K์ŠคํŽ˜์ด๋“œ - -pobi๋Š” ํ•œ์žฅ์˜ ์นด๋“œ๋ฅผ ๋” ๋ฐ›๊ฒ ์Šต๋‹ˆ๊นŒ?(์˜ˆ๋Š” y, ์•„๋‹ˆ์˜ค๋Š” n) -y -pobi์นด๋“œ: 2ํ•˜ํŠธ, 8์ŠคํŽ˜์ด๋“œ, Aํด๋กœ๋ฒ„ -pobi๋Š” ํ•œ์žฅ์˜ ์นด๋“œ๋ฅผ ๋” ๋ฐ›๊ฒ ์Šต๋‹ˆ๊นŒ?(์˜ˆ๋Š” y, ์•„๋‹ˆ์˜ค๋Š” n) -n -pobi์นด๋“œ: 2ํ•˜ํŠธ, 8์ŠคํŽ˜์ด๋“œ, Aํด๋กœ๋ฒ„ -jason์€ ํ•œ์žฅ์˜ ์นด๋“œ๋ฅผ ๋” ๋ฐ›๊ฒ ์Šต๋‹ˆ๊นŒ?(์˜ˆ๋Š” y, ์•„๋‹ˆ์˜ค๋Š” n) -n -jason์นด๋“œ: 7ํด๋กœ๋ฒ„, K์ŠคํŽ˜์ด๋“œ - -๋”œ๋Ÿฌ๋Š” 16์ดํ•˜๋ผ ํ•œ์žฅ์˜ ์นด๋“œ๋ฅผ ๋” ๋ฐ›์•˜์Šต๋‹ˆ๋‹ค. - -๋”œ๋Ÿฌ ์นด๋“œ: 3๋‹ค์ด์•„๋ชฌ๋“œ, 9ํด๋กœ๋ฒ„, 8๋‹ค์ด์•„๋ชฌ๋“œ - ๊ฒฐ๊ณผ: 20 -pobi์นด๋“œ: 2ํ•˜ํŠธ, 8์ŠคํŽ˜์ด๋“œ, Aํด๋กœ๋ฒ„ - ๊ฒฐ๊ณผ: 21 -jason์นด๋“œ: 7ํด๋กœ๋ฒ„, K์ŠคํŽ˜์ด๋“œ - ๊ฒฐ๊ณผ: 17 - -## ์ตœ์ข… ์ŠนํŒจ -๋”œ๋Ÿฌ: 1์Šน 1ํŒจ -pobi: ์Šน -jason: ํŒจ -``` - -## โœ… 2๋‹จ๊ณ„ - ๋ธ”๋ž™์žญ ๊ตฌํ˜„ - -- 1๋‹จ๊ณ„ ๋ฏธ์…˜์ด ์–ด๋Š์ •๋„ ๊ตฌํ˜„๋œ ํ›„์— ๊ณต๊ฐœํ•  ์˜ˆ์ • - -## ๐Ÿ–ฅ๏ธ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์š”๊ตฌ ์‚ฌํ•ญ -- indent(์ธ๋ดํŠธ, ๋“ค์—ฌ์“ฐ๊ธฐ) depth๋ฅผ 3๋ฅผ ๋„˜์ง€ ์•Š๋„๋ก ๊ตฌํ˜„ํ•œ๋‹ค. 2๊นŒ์ง€๋งŒ ํ—ˆ์šฉํ•œ๋‹ค. ( ๊ฐœ์ธ์˜ ์—ญ๋Ÿ‰์— ๋งž์ถฐ 1๊นŒ์ง€ ํ—ˆ์šฉํ•˜์—ฌ ์ง„ํ–‰ํ•ด๋ณผ ๊ฒƒ์„ ์ถ”์ฒœ ) - - ์˜ˆ๋ฅผ ๋“ค์–ด while๋ฌธ ์•ˆ์— if๋ฌธ์ด ์žˆ์œผ๋ฉด ๋“ค์—ฌ์“ฐ๊ธฐ๋Š” 2์ด๋‹ค. - - ํžŒํŠธ: indent(์ธ๋ดํŠธ, ๋“ค์—ฌ์“ฐ๊ธฐ) depth๋ฅผ ์ค„์ด๋Š” ์ข‹์€ ๋ฐฉ๋ฒ•์€ ํ•จ์ˆ˜(๋˜๋Š” ๋ฉ”์„œ๋“œ)๋ฅผ ๋ถ„๋ฆฌํ•˜๋ฉด ๋œ๋‹ค. -- 3ํ•ญ ์—ฐ์‚ฐ์ž๋ฅผ ์“ฐ์ง€ ์•Š๋Š”๋‹ค. -- else ์˜ˆ์•ฝ์–ด๋ฅผ ์“ฐ์ง€ ์•Š๋Š”๋‹ค. - - else ์˜ˆ์•ฝ์–ด๋ฅผ ์“ฐ์ง€ ๋ง๋ผ๊ณ  ํ•˜๋‹ˆ switch/case๋กœ ๊ตฌํ˜„ํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ๋Š”๋ฐ switch/case๋„ ํ—ˆ์šฉํ•˜์ง€ ์•Š๋Š”๋‹ค. - - ํžŒํŠธ: if๋ฌธ์—์„œ ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ๊ตฌํ˜„ํ•˜๋ฉด else ์˜ˆ์•ฝ์–ด๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š์•„๋„ ๋œ๋‹ค. -- ํ•ต์‹ฌ ๋กœ์ง์„ ๊ตฌํ˜„ํ•˜๋Š” ์ฝ”๋“œ์™€ UI๋ฅผ ๋‹ด๋‹นํ•˜๋Š” ๋กœ์ง์„ ๊ตฌ๋ถ„ํ•œ๋‹ค. - - UI ๋กœ์ง์„ InputView, ResultView์™€ ๊ฐ™์€ ํด๋ž˜์Šค๋ฅผ ์ถ”๊ฐ€ํ•ด ๋ถ„๋ฆฌํ•œ๋‹ค. -- ํ•จ์ˆ˜(๋˜๋Š” ๋ฉ”์„œ๋“œ)์˜ ๊ธธ์ด๊ฐ€ 10๋ผ์ธ์„ ๋„˜์–ด๊ฐ€์ง€ ์•Š๋„๋ก ๊ตฌํ˜„ํ•œ๋‹ค. -- ํ•จ์ˆ˜(๋˜๋Š” ๋ฉ”์†Œ๋“œ)๊ฐ€ ํ•œ ๊ฐ€์ง€ ์ผ๋งŒ ํ•˜๋„๋ก ์ตœ๋Œ€ํ•œ ์ž‘๊ฒŒ ๋งŒ๋“ค์–ด๋ผ. - -## ๐Ÿ”ฅ ์ถ”๊ฐ€๋œ ์š”๊ตฌ ์‚ฌํ•ญ -- Java 11 ์œผ๋กœ ๋ณ€๊ฒฝํ•œ๋‹ค. -- ๋ชจ๋“  ์›์‹œ ๊ฐ’๊ณผ ๋ฌธ์ž์—ด์„ ํฌ์žฅํ•œ๋‹ค [์ฐธ๊ณ  ๊ธ€](https://tecoble.techcourse.co.kr/post/2020-05-29-wrap-primitive-type/) -- ๊ตฌํ˜„ํ•œ ๊ธฐ๋Šฅ์— Test๋ฅผ ์ถ”๊ฐ€ํ•œ๋‹ค. ๋‹จ, UI(System.out, System.in) ๋กœ์ง์€ ์ œ์™ธ -- ๋ฐฐ์—ด ๋Œ€์‹  ์ปฌ๋ ‰์…˜์„ ์‚ฌ์šฉํ•œ๋‹ค. -- 3๊ฐœ ์ด์ƒ์˜ ์ธ์Šคํ„ด์Šค ๋ณ€์ˆ˜๋ฅผ ๊ฐ€์ง„ ํด๋ž˜์Šค๋ฅผ ์“ฐ์ง€ ์•Š๋Š”๋‹ค. -- ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด์—์„œ ๋ฐœ์ƒํ•˜๋Š” ์ค‘๋ณต ์ฝ”๋“œ๋ฅผ ์ œ๊ฑฐํ•ด์•ผ ํ•œ๋‹ค. -- ์ผ๊ธ‰ ์ปฌ๋ ‰์…˜์„ ์“ด๋‹ค. [์ฐธ๊ณ  ๊ธ€](https://jojoldu.tistory.com/412) - -## ๐Ÿ“š ๊ณผ์ œ ์ง„ํ–‰ ์š”๊ตฌ ์‚ฌํ•ญ -- ๋ฏธ์…˜์€ ํ•ด๋‹น ์ €์žฅ์†Œ๋ฅผ Fork/Cloneํ•จ์œผ๋กœ๋ถ€ํ„ฐ ์‹œ์ž‘๋œ๋‹ค. -- ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•˜๊ธฐ ์ „์— java-baseball/docs/README.md ํŒŒ์ผ์— ๊ตฌํ˜„ํ•  ๊ธฐ๋Šฅ ๋ชฉ๋ก์„ ์ •๋ฆฌํ•ด ์ถ”๊ฐ€ํ•œ๋‹ค. -- Git์˜ ์ปค๋ฐ‹ ๋‹จ์œ„๋Š” ์•ž ๋‹จ๊ณ„์—์„œ README.md ํŒŒ์ผ์— ์ •๋ฆฌํ•œ ๊ธฐ๋Šฅ ๋ชฉ๋ก ๋‹จ์œ„๋กœ ์ถ”๊ฐ€ํ•œ๋‹ค. -- ์ปค๋ฐ‹ ๋ฉ”์‹œ์ง€ [์ปจ๋ฒค์…˜ ๊ฐ€์ด๋“œ](https://gist.github.com/stephenparish/9941e89d80e2bc58a153)๋ฅผ ์ฐธ๊ณ ํ•ด ์ปค๋ฐ‹ ๋ฉ”์‹œ์ง€๋ฅผ ์ž‘์„ฑํ•œ๋‹ค. +# ๊ธฐ๋Šฅ ๋ชฉ๋ก + +
+ +## view + +### inputView + +- [ ] ์ž…๋ ฅ + - [ ] ํ”Œ๋ ˆ์ด์–ด ๋ชฉ๋ก ์ž…๋ ฅ + - [ ] ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์นด๋“œ๋ฅผ ๋ฐ›์„์ง€ ์—ฌ๋ถ€(y/n) ์ž…๋ ฅ + +### outputView + +- [ ] ์ถœ๋ ฅ + - [ ] ํ”Œ๋ ˆ์ด์–ด ์ด๋ฆ„ ์ž…๋ ฅํ•˜๊ธฐ ๋ฌธ๊ตฌ + - [ ] ๊ฒŒ์ž„ ์‹œ์ž‘ ์‹œ ์นด๋“œ 2์žฅ ๋ฐฐ๋ถ„์— ๋Œ€ํ•œ ๋ฌธ๊ตฌ + - [ ] ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์นด๋“œ๋ฅผ ๋ฐ›์„์ง€ ์—ฌ๋ถ€(y/n) ๋ฌป๋Š” ๋ฌธ๊ตฌ + - [ ] ์ฐธ์—ฌ์ž ์นด๋“œ ๋ฆฌ์ŠคํŠธ ๋‚ด์˜ ์นด๋“œ ์ถœ๋ ฅ (jason์นด๋“œ: 7ํด๋กœ๋ฒ„, K์ŠคํŽ˜์ด๋“œ) + - [ ] ๋”œ๋Ÿฌ ์นด๋“œ ์ถ”๊ฐ€์ ์œผ๋กœ ๋ฐ›์•˜์„ ๋•Œ ๋ฌธ๊ตฌ + +- [ ] ๊ฒฐ๊ณผ ์ถœ๋ ฅ + - [ ] ์ ์ˆ˜ ๊ณ„์‚ฐ ๊ฒฐ๊ณผ ์ถœ๋ ฅ + - [ ] ์ตœ์ข… ์ŠนํŒจ ์ถœ๋ ฅ + +
+ +## domain + +- [ ] ์ฐธ๊ฐ€์ž(์ถ”์ƒ ํด๋ž˜์Šค) + +- [ ] ํ”Œ๋ ˆ์ด์–ด(์ฐธ๊ฐ€์ž ์ƒ์†) + +- [ ] ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ + +- [ ] ๋”œ๋Ÿฌ(์ฐธ๊ฐ€์ž ์ƒ์†) + +- [ ] ์นด๋“œ ๋ฐฐ๋ถ„ + - [ ] ๊ฒŒ์ž„ ์‹œ์ž‘ ์‹œ ์นด๋“œ 2์žฅ ์”ฉ ์ฐธ๊ฐ€์ž๋“ค์— ์นด๋“œ๋ฑ์—์„œ ์ถ”์ถœํ•˜์—ฌ ๋ฐฐ๋ถ„ + - [ ] ํ”Œ๋ ˆ์ด์–ด์— ์นด๋“œ 1์žฅ ์นด๋“œ๋ฑ์—์„œ ์ถ”์ถœํ•˜์—ฌ ๋ฐฐ๋ถ„ + - [ ] ๋”œ๋Ÿฌ์— ์นด๋“œ 1์žฅ ์นด๋“œ๋ฑ์—์„œ ์ถ”์ถœํ•˜์—ฌ ๋ฐฐ๋ถ„ + +- [ ] ์นด๋“œ ๋ฆฌ์ŠคํŠธ: ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๋ฐฐ๋ถ„ ๋ฐ›์€ ์นด๋“œ๋“ค ๋‹ด๋Š” ๋ฆฌ์ŠคํŠธ + - [ ] ์นด๋“œ ๋ฆฌ์ŠคํŠธ์— ์นด๋“œ ์ถ”๊ฐ€ + +- [ ] ์นด๋“œ ์‹ฌ๋ณผ ์ƒ์ˆ˜ + +- [ ] ์นด๋“œ: ์‹ฌ๋ณผ(ํ•˜ํŠธ, ์ŠคํŽ˜์ด๋“œ, ๋‹ค์ด์•„๋ชฌ๋“œ, ํด๋กœ๋ฒ„)๊ณผ ์ˆซ์ž(์—์ด์Šค~ํ‚น) ์กฐํ•ฉ์œผ๋กœ ์ด๋ฃจ์–ด์ง„ ์นด๋“œ + +- [ ] ์นด๋“œ๋ฑ: 52๊ฐ€์ง€ ์นด๋“œ ๋‹ด๊ณ  ์žˆ๋Š” ํ•˜๋‚˜์˜ ์นด๋“œ๋ฑ + - [ ] ์นด๋“œ๋ฑ์—์„œ ์นด๋“œ ์ถ”์ถœํ•˜์—ฌ ๋ฐ˜ํ™˜ + +- [ ] ์ ์ˆ˜ ๊ณ„์‚ฐ + - [ ] ์นด๋“œ ๋ฆฌ์ŠคํŠธ์— ์žˆ๋Š” ์นด๋“œ์— ๋Œ€ํ•ด ์ตœ์ข… ์ ์ˆ˜ ๊ณ„์‚ฐํ•˜์—ฌ ๋ฐ˜ํ™˜ + +- [ ] ์ตœ์ข… ์ŠนํŒจ ํŒ๋‹จ + - [ ] ์ฐธ์—ฌ์ž๋“ค ์ตœ์ข… ์ŠนํŒจ + +
+ +## controller + +- [ ] ๊ฒŒ์ž„ ๋งค๋‹ˆ์ € + - [ ] ๊ฒŒ์ž„ ์‹œ์ž‘ + - [ ] ์ฐธ๊ฐ€์ž ์ƒ์„ฑ + - [ ] ์นด๋“œ ๋ฐฐ๋ถ„ + - [ ] ์ ์ˆ˜ ๊ณ„์‚ฐ ๊ฒฐ๊ณผ ์ถœ๋ ฅ + - [ ] ์ตœ์ข… ์ŠนํŒจ ๊ฒฐ๊ณผ ์ถœ๋ ฅ + - [ ] ์ฐธ๊ฐ€์ž ์ƒ์„ฑ + - [ ] ํ”Œ๋ ˆ์ด์–ด ์ด๋ฆ„ ์ž…๋ ฅ ๋ฐ›๊ธฐ + - [ ] ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ ์ƒ์„ฑ + - [ ] ํ”Œ๋ ˆ์ด์–ด ์ƒ์„ฑ + - [ ] ๋”œ๋Ÿฌ ์ƒ์„ฑ + - [ ] ์นด๋“œ ๋ฐฐ๋ถ„ + - [ ] ํ”Œ๋ ˆ์ด์–ด๋“ค์—๊ฒŒ ์นด๋“œ ์ถ”๊ฐ€ ์—ฌ๋ถ€ ๋ฌป๊ธฐ (๋ชจ๋“  ํ”Œ๋ ˆ์ด์–ด์— ๋Œ€ํ•ด, ๊ฐ ํ”Œ๋ ˆ์ด์–ด ๊ทธ๋งŒ ์ถ”๊ฐ€ํ•  ๋•Œ๊นŒ์ง€) + - [ ] ๋”œ๋Ÿฌ ์นด๋“œ ํ•ฉ 16์ดํ•˜ ์‹œ ์นด๋“œ ์ถ”๊ฐ€ From ff1a0d58372044033503791c04adacb39d08e485 Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Sun, 28 Jan 2024 13:18:01 +0900 Subject: [PATCH 02/48] =?UTF-8?q?README.md:=20=EA=B8=B0=EB=8A=A5=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8e0bf21c..506281a7 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ ## domain -- [ ] ์ฐธ๊ฐ€์ž(์ถ”์ƒ ํด๋ž˜์Šค) +- [ ] ์ฐธ๊ฐ€์ž(ํด๋ž˜์Šค) - [ ] ํ”Œ๋ ˆ์ด์–ด(์ฐธ๊ฐ€์ž ์ƒ์†) From 35424f89a753fb241ae9eceb71f4792a8c26786e Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Mon, 29 Jan 2024 09:48:15 +0900 Subject: [PATCH 03/48] =?UTF-8?q?=ED=94=8C=EB=A0=88=EC=9D=B4=EC=96=B4=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=EC=97=90=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 506281a7..72964ab4 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ ### inputView - [ ] ์ž…๋ ฅ - - [ ] ํ”Œ๋ ˆ์ด์–ด ๋ชฉ๋ก ์ž…๋ ฅ + - [ ] ํ”Œ๋ ˆ์ด์–ด ๋ชฉ๋ก ์ž…๋ ฅ - [ ] ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์นด๋“œ๋ฅผ ๋ฐ›์„์ง€ ์—ฌ๋ถ€(y/n) ์ž…๋ ฅ ### outputView @@ -32,6 +32,9 @@ - [ ] ํ”Œ๋ ˆ์ด์–ด(์ฐธ๊ฐ€์ž ์ƒ์†) - [ ] ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ + - [ ] ํ”Œ๋ ˆ์ด์–ด ์ด๋ฆ„ ๋ชฉ๋ก ๋ฐ›์•„์„œ ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ ์ƒ์„ฑ + - [ ] ํ”Œ๋ ˆ์ด์–ด ์ด๋ฆ„ ์ค‘๋ณต ์˜ˆ์™ธ์ฒ˜๋ฆฌ + - [ ] ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ ๋ฐ˜ํ™˜ - [ ] ๋”œ๋Ÿฌ(์ฐธ๊ฐ€์ž ์ƒ์†) From 8aa05485ef4d727609fb1d75b95754f8eb8a44cc Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Mon, 29 Jan 2024 09:52:21 +0900 Subject: [PATCH 04/48] =?UTF-8?q?=EC=9E=85=EB=A0=A5/=ED=94=8C=EB=A0=88?= =?UTF-8?q?=EC=9D=B4=EC=96=B4=20=EB=AA=A9=EB=A1=9D=20=EC=9E=85=EB=A0=A5=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- src/main/java/view/inputview/InputView.java | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/main/java/view/inputview/InputView.java diff --git a/README.md b/README.md index 72964ab4..1b260f6c 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ ### inputView - [ ] ์ž…๋ ฅ - - [ ] ํ”Œ๋ ˆ์ด์–ด ๋ชฉ๋ก ์ž…๋ ฅ + - [x] ํ”Œ๋ ˆ์ด์–ด ๋ชฉ๋ก ์ž…๋ ฅ - [ ] ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์นด๋“œ๋ฅผ ๋ฐ›์„์ง€ ์—ฌ๋ถ€(y/n) ์ž…๋ ฅ ### outputView diff --git a/src/main/java/view/inputview/InputView.java b/src/main/java/view/inputview/InputView.java new file mode 100644 index 00000000..9d9b0d7e --- /dev/null +++ b/src/main/java/view/inputview/InputView.java @@ -0,0 +1,13 @@ +package view.inputview; + +import java.util.Scanner; + +public class InputView { + + public String inputPlayerName() { + Scanner sc = new Scanner(System.in); + String playerNameStr = sc.nextLine(); + return playerNameStr; + } + +} From b72e864d4cbbef25e30054e1b9572d7195e8a68d Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Mon, 29 Jan 2024 09:56:12 +0900 Subject: [PATCH 05/48] =?UTF-8?q?=EC=B0=B8=EA=B0=80=EC=9E=90(=ED=81=B4?= =?UTF-8?q?=EB=9E=98=EC=8A=A4)=20=EA=B8=B0=EB=8A=A5=201=EC=B0=A8=20?= =?UTF-8?q?=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- src/main/java/domain/Participant.java | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/main/java/domain/Participant.java diff --git a/README.md b/README.md index 1b260f6c..d195f142 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ ## domain -- [ ] ์ฐธ๊ฐ€์ž(ํด๋ž˜์Šค) +- [x] ์ฐธ๊ฐ€์ž(ํด๋ž˜์Šค) - [ ] ํ”Œ๋ ˆ์ด์–ด(์ฐธ๊ฐ€์ž ์ƒ์†) diff --git a/src/main/java/domain/Participant.java b/src/main/java/domain/Participant.java new file mode 100644 index 00000000..c1b42f83 --- /dev/null +++ b/src/main/java/domain/Participant.java @@ -0,0 +1,20 @@ +package domain; + +public class Participant { + private String name; + private CardList cardList; + + public Participant(String name) { + this.name = name; + this.cardList = new CardList(); + } + + public String getName() { + return this.name; + } + + public CardList getCardList() { + return this.cardList; + } + +} From 6aa4b338f7051365fd3e1a8caa14c0c47514eb8c Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Mon, 29 Jan 2024 09:57:29 +0900 Subject: [PATCH 06/48] =?UTF-8?q?=ED=94=8C=EB=A0=88=EC=9D=B4=EC=96=B4(?= =?UTF-8?q?=EC=B0=B8=EA=B0=80=EC=9E=90=20=EC=83=81=EC=86=8D),=20=EB=94=9C?= =?UTF-8?q?=EB=9F=AC(=EC=B0=B8=EA=B0=80=EC=9E=90=20=EC=83=81=EC=86=8D)=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/domain/Dealer.java | 8 ++++++++ src/main/java/domain/Player.java | 7 +++++++ 2 files changed, 15 insertions(+) create mode 100644 src/main/java/domain/Dealer.java create mode 100644 src/main/java/domain/Player.java diff --git a/src/main/java/domain/Dealer.java b/src/main/java/domain/Dealer.java new file mode 100644 index 00000000..ebe07f2f --- /dev/null +++ b/src/main/java/domain/Dealer.java @@ -0,0 +1,8 @@ +package domain; + +public class Dealer extends Participant{ + + public Dealer() { + super("๋”œ๋Ÿฌ"); + } +} \ No newline at end of file diff --git a/src/main/java/domain/Player.java b/src/main/java/domain/Player.java new file mode 100644 index 00000000..a976929f --- /dev/null +++ b/src/main/java/domain/Player.java @@ -0,0 +1,7 @@ +package domain; + +public class Player extends Participant{ + public Player(String name) { + super(name); + } +} From 18a50a88566a6bfa55a904237fd04a15e5f97093 Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Mon, 29 Jan 2024 10:03:04 +0900 Subject: [PATCH 07/48] =?UTF-8?q?=ED=94=8C=EB=A0=88=EC=9D=B4=EC=96=B4=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EA=B8=B0=EB=8A=A5=20=EC=99=84?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 12 +++++----- src/main/java/domain/PlayerList.java | 36 ++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 src/main/java/domain/PlayerList.java diff --git a/README.md b/README.md index d195f142..61c4175b 100644 --- a/README.md +++ b/README.md @@ -29,14 +29,14 @@ - [x] ์ฐธ๊ฐ€์ž(ํด๋ž˜์Šค) -- [ ] ํ”Œ๋ ˆ์ด์–ด(์ฐธ๊ฐ€์ž ์ƒ์†) +- [x] ํ”Œ๋ ˆ์ด์–ด(์ฐธ๊ฐ€์ž ์ƒ์†) -- [ ] ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ - - [ ] ํ”Œ๋ ˆ์ด์–ด ์ด๋ฆ„ ๋ชฉ๋ก ๋ฐ›์•„์„œ ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ ์ƒ์„ฑ - - [ ] ํ”Œ๋ ˆ์ด์–ด ์ด๋ฆ„ ์ค‘๋ณต ์˜ˆ์™ธ์ฒ˜๋ฆฌ - - [ ] ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ ๋ฐ˜ํ™˜ +- [x] ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ + - [x] ํ”Œ๋ ˆ์ด์–ด ์ด๋ฆ„ ๋ชฉ๋ก ๋ฐ›์•„์„œ ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ ์ƒ์„ฑ + - [x] ํ”Œ๋ ˆ์ด์–ด ์ด๋ฆ„ ์ค‘๋ณต ์˜ˆ์™ธ์ฒ˜๋ฆฌ + - [x] ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ ๋ฐ˜ํ™˜ -- [ ] ๋”œ๋Ÿฌ(์ฐธ๊ฐ€์ž ์ƒ์†) +- [x] ๋”œ๋Ÿฌ(์ฐธ๊ฐ€์ž ์ƒ์†) - [ ] ์นด๋“œ ๋ฐฐ๋ถ„ - [ ] ๊ฒŒ์ž„ ์‹œ์ž‘ ์‹œ ์นด๋“œ 2์žฅ ์”ฉ ์ฐธ๊ฐ€์ž๋“ค์— ์นด๋“œ๋ฑ์—์„œ ์ถ”์ถœํ•˜์—ฌ ๋ฐฐ๋ถ„ diff --git a/src/main/java/domain/PlayerList.java b/src/main/java/domain/PlayerList.java new file mode 100644 index 00000000..9adc7b44 --- /dev/null +++ b/src/main/java/domain/PlayerList.java @@ -0,0 +1,36 @@ +package domain; + +import java.util.ArrayList; +import java.util.List; + +public class PlayerList { + private List playerList; + + public PlayerList() { + this.playerList = new ArrayList(); + } + + public void generatePlayerList(String playerNameStr) { + String[] playerNameList = playerNameStr.split(","); + validateDuplicatedPlayerName(playerNameList); + for (String playerName : playerNameList) { + Player player = new Player(playerName.trim()); + this.playerList.add(player); + } + } + + private void validateDuplicatedPlayerName(String[] playerNameList) { + List processedPlayerNameList = new ArrayList(); + for (String playerName : playerNameList) { + if (processedPlayerNameList.contains(playerName.trim())) { + throw new IllegalArgumentException("ํ”Œ๋ ˆ์ด์–ด ์ด๋ฆ„ ์ค‘๋ณต"); + } + processedPlayerNameList.add(playerName.trim()); + } + } + + public List getPlayerList() { + return this.playerList; + } + +} From e3e7227b762ca420ef358eb99960da83008a0857 Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Mon, 29 Jan 2024 10:04:36 +0900 Subject: [PATCH 08/48] =?UTF-8?q?README.md:=20controller/=EA=B2=8C?= =?UTF-8?q?=EC=9E=84=20=EB=A7=A4=EB=8B=88=EC=A0=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 61c4175b..7b27393f 100644 --- a/README.md +++ b/README.md @@ -71,9 +71,9 @@ - [ ] ์ตœ์ข… ์ŠนํŒจ ๊ฒฐ๊ณผ ์ถœ๋ ฅ - [ ] ์ฐธ๊ฐ€์ž ์ƒ์„ฑ - [ ] ํ”Œ๋ ˆ์ด์–ด ์ด๋ฆ„ ์ž…๋ ฅ ๋ฐ›๊ธฐ - - [ ] ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ ์ƒ์„ฑ - - [ ] ํ”Œ๋ ˆ์ด์–ด ์ƒ์„ฑ - - [ ] ๋”œ๋Ÿฌ ์ƒ์„ฑ + - [ ] ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ ์ƒ์„ฑ + - [ ] ํ”Œ๋ ˆ์ด์–ด ์ƒ์„ฑ + - [ ] ๋”œ๋Ÿฌ ์ƒ์„ฑ - [ ] ์นด๋“œ ๋ฐฐ๋ถ„ - [ ] ํ”Œ๋ ˆ์ด์–ด๋“ค์—๊ฒŒ ์นด๋“œ ์ถ”๊ฐ€ ์—ฌ๋ถ€ ๋ฌป๊ธฐ (๋ชจ๋“  ํ”Œ๋ ˆ์ด์–ด์— ๋Œ€ํ•ด, ๊ฐ ํ”Œ๋ ˆ์ด์–ด ๊ทธ๋งŒ ์ถ”๊ฐ€ํ•  ๋•Œ๊นŒ์ง€) - [ ] ๋”œ๋Ÿฌ ์นด๋“œ ํ•ฉ 16์ดํ•˜ ์‹œ ์นด๋“œ ์ถ”๊ฐ€ From 0871be7f4c6c3054c537db73dd53697ea43d24ad Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Mon, 29 Jan 2024 14:35:19 +0900 Subject: [PATCH 09/48] =?UTF-8?q?=EC=B6=9C=EB=A0=A5/=ED=94=8C=EB=A0=88?= =?UTF-8?q?=EC=9D=B4=EC=96=B4=20=EC=9D=B4=EB=A6=84=20=EC=9E=85=EB=A0=A5?= =?UTF-8?q?=ED=95=98=EA=B8=B0=20=EB=AC=B8=EA=B5=AC=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- .../domain/{PlayerList.java => PlayerListGenerator.java} | 0 src/main/java/view/outputview/OutputView.java | 7 +++++++ 3 files changed, 8 insertions(+), 1 deletion(-) rename src/main/java/domain/{PlayerList.java => PlayerListGenerator.java} (100%) create mode 100644 src/main/java/view/outputview/OutputView.java diff --git a/README.md b/README.md index 7b27393f..4634008a 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ ### outputView - [ ] ์ถœ๋ ฅ - - [ ] ํ”Œ๋ ˆ์ด์–ด ์ด๋ฆ„ ์ž…๋ ฅํ•˜๊ธฐ ๋ฌธ๊ตฌ + - [x] ํ”Œ๋ ˆ์ด์–ด ์ด๋ฆ„ ์ž…๋ ฅํ•˜๊ธฐ ๋ฌธ๊ตฌ - [ ] ๊ฒŒ์ž„ ์‹œ์ž‘ ์‹œ ์นด๋“œ 2์žฅ ๋ฐฐ๋ถ„์— ๋Œ€ํ•œ ๋ฌธ๊ตฌ - [ ] ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์นด๋“œ๋ฅผ ๋ฐ›์„์ง€ ์—ฌ๋ถ€(y/n) ๋ฌป๋Š” ๋ฌธ๊ตฌ - [ ] ์ฐธ์—ฌ์ž ์นด๋“œ ๋ฆฌ์ŠคํŠธ ๋‚ด์˜ ์นด๋“œ ์ถœ๋ ฅ (jason์นด๋“œ: 7ํด๋กœ๋ฒ„, K์ŠคํŽ˜์ด๋“œ) diff --git a/src/main/java/domain/PlayerList.java b/src/main/java/domain/PlayerListGenerator.java similarity index 100% rename from src/main/java/domain/PlayerList.java rename to src/main/java/domain/PlayerListGenerator.java diff --git a/src/main/java/view/outputview/OutputView.java b/src/main/java/view/outputview/OutputView.java new file mode 100644 index 00000000..47151c5a --- /dev/null +++ b/src/main/java/view/outputview/OutputView.java @@ -0,0 +1,7 @@ +package view.outputview; + +public class OutputView { + public void printInputPlayerNameMessage() { + System.out.println("๊ฒŒ์ž„์— ์ฐธ์—ฌํ•  ์‚ฌ๋žŒ์˜ ์ด๋ฆ„์„ ์ž…๋ ฅํ•˜์„ธ์š”.(์‰ผํ‘œ ๊ธฐ์ค€์œผ๋กœ ๋ถ„๋ฆฌ)"); + } +} From a467680be1ae9ddffad29f10a85b7ab385064aee Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Mon, 29 Jan 2024 15:34:09 +0900 Subject: [PATCH 10/48] =?UTF-8?q?README.md:=20=EC=B9=B4=EB=93=9C=20?= =?UTF-8?q?=EC=88=AB=EC=9E=90=20=EC=83=81=EC=88=98(=EC=97=90=EC=9D=B4?= =?UTF-8?q?=EC=8A=A4~=EC=9E=AD,=ED=80=B8,=ED=82=B9)=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4634008a..35fe81b3 100644 --- a/README.md +++ b/README.md @@ -43,10 +43,12 @@ - [ ] ํ”Œ๋ ˆ์ด์–ด์— ์นด๋“œ 1์žฅ ์นด๋“œ๋ฑ์—์„œ ์ถ”์ถœํ•˜์—ฌ ๋ฐฐ๋ถ„ - [ ] ๋”œ๋Ÿฌ์— ์นด๋“œ 1์žฅ ์นด๋“œ๋ฑ์—์„œ ์ถ”์ถœํ•˜์—ฌ ๋ฐฐ๋ถ„ -- [ ] ์นด๋“œ ๋ฆฌ์ŠคํŠธ: ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๋ฐฐ๋ถ„ ๋ฐ›์€ ์นด๋“œ๋“ค ๋‹ด๋Š” ๋ฆฌ์ŠคํŠธ +- [ ] ์ฐธ๊ฐ€์ž ์นด๋“œ ๋ฆฌ์ŠคํŠธ: ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๋ฐฐ๋ถ„ ๋ฐ›์€ ์นด๋“œ๋“ค ๋‹ด๋Š” ๋ฆฌ์ŠคํŠธ - [ ] ์นด๋“œ ๋ฆฌ์ŠคํŠธ์— ์นด๋“œ ์ถ”๊ฐ€ -- [ ] ์นด๋“œ ์‹ฌ๋ณผ ์ƒ์ˆ˜ +- [ ] ์นด๋“œ ์‹ฌ๋ณผ ์ƒ์ˆ˜(ํ•˜ํŠธ~์ŠคํŽ˜์ด๋“œ) + +- [ ] ์นด๋“œ ์ˆซ์ž ์ƒ์ˆ˜(์—์ด์Šค~์žญ,ํ€ธ,ํ‚น) - [ ] ์นด๋“œ: ์‹ฌ๋ณผ(ํ•˜ํŠธ, ์ŠคํŽ˜์ด๋“œ, ๋‹ค์ด์•„๋ชฌ๋“œ, ํด๋กœ๋ฒ„)๊ณผ ์ˆซ์ž(์—์ด์Šค~ํ‚น) ์กฐํ•ฉ์œผ๋กœ ์ด๋ฃจ์–ด์ง„ ์นด๋“œ From e333a06325c0bd1d49c5d31f89f9e6d23ac5d26a Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Mon, 29 Jan 2024 15:54:11 +0900 Subject: [PATCH 11/48] =?UTF-8?q?=EC=B9=B4=EB=93=9C,=20=EC=B9=B4=EB=93=9C?= =?UTF-8?q?=EB=8D=B1,=20=EC=B9=B4=EB=93=9C=20=EC=8B=AC=EB=B3=BC,=20?= =?UTF-8?q?=EC=B9=B4=EB=93=9C=20=EC=88=AB=EC=9E=90=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 10 ++++---- src/main/java/domain/Card.java | 17 +++++++++++++ src/main/java/domain/CardDeck.java | 38 ++++++++++++++++++++++++++++++ src/main/java/domain/CardRank.java | 19 +++++++++++++++ src/main/java/domain/CardSuit.java | 16 +++++++++++++ 5 files changed, 95 insertions(+), 5 deletions(-) create mode 100644 src/main/java/domain/Card.java create mode 100644 src/main/java/domain/CardDeck.java create mode 100644 src/main/java/domain/CardRank.java create mode 100644 src/main/java/domain/CardSuit.java diff --git a/README.md b/README.md index 35fe81b3..8a631e7b 100644 --- a/README.md +++ b/README.md @@ -46,14 +46,14 @@ - [ ] ์ฐธ๊ฐ€์ž ์นด๋“œ ๋ฆฌ์ŠคํŠธ: ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๋ฐฐ๋ถ„ ๋ฐ›์€ ์นด๋“œ๋“ค ๋‹ด๋Š” ๋ฆฌ์ŠคํŠธ - [ ] ์นด๋“œ ๋ฆฌ์ŠคํŠธ์— ์นด๋“œ ์ถ”๊ฐ€ -- [ ] ์นด๋“œ ์‹ฌ๋ณผ ์ƒ์ˆ˜(ํ•˜ํŠธ~์ŠคํŽ˜์ด๋“œ) +- [x] ์นด๋“œ ์‹ฌ๋ณผ ์ƒ์ˆ˜(ํ•˜ํŠธ~์ŠคํŽ˜์ด๋“œ) -- [ ] ์นด๋“œ ์ˆซ์ž ์ƒ์ˆ˜(์—์ด์Šค~์žญ,ํ€ธ,ํ‚น) +- [x] ์นด๋“œ ์ˆซ์ž ์ƒ์ˆ˜(์—์ด์Šค~์žญ,ํ€ธ,ํ‚น) -- [ ] ์นด๋“œ: ์‹ฌ๋ณผ(ํ•˜ํŠธ, ์ŠคํŽ˜์ด๋“œ, ๋‹ค์ด์•„๋ชฌ๋“œ, ํด๋กœ๋ฒ„)๊ณผ ์ˆซ์ž(์—์ด์Šค~ํ‚น) ์กฐํ•ฉ์œผ๋กœ ์ด๋ฃจ์–ด์ง„ ์นด๋“œ +- [x] ์นด๋“œ: ์‹ฌ๋ณผ(ํ•˜ํŠธ, ์ŠคํŽ˜์ด๋“œ, ๋‹ค์ด์•„๋ชฌ๋“œ, ํด๋กœ๋ฒ„)๊ณผ ์ˆซ์ž(์—์ด์Šค~ํ‚น) ์กฐํ•ฉ์œผ๋กœ ์ด๋ฃจ์–ด์ง„ ์นด๋“œ -- [ ] ์นด๋“œ๋ฑ: 52๊ฐ€์ง€ ์นด๋“œ ๋‹ด๊ณ  ์žˆ๋Š” ํ•˜๋‚˜์˜ ์นด๋“œ๋ฑ - - [ ] ์นด๋“œ๋ฑ์—์„œ ์นด๋“œ ์ถ”์ถœํ•˜์—ฌ ๋ฐ˜ํ™˜ +- [x] ์นด๋“œ๋ฑ: 52๊ฐ€์ง€ ์นด๋“œ ๋‹ด๊ณ  ์žˆ๋Š” ํ•˜๋‚˜์˜ ์นด๋“œ๋ฑ + - [x] ์นด๋“œ๋ฑ์—์„œ ์นด๋“œ ์ถ”์ถœํ•˜์—ฌ ๋ฐ˜ํ™˜ - [ ] ์ ์ˆ˜ ๊ณ„์‚ฐ - [ ] ์นด๋“œ ๋ฆฌ์ŠคํŠธ์— ์žˆ๋Š” ์นด๋“œ์— ๋Œ€ํ•ด ์ตœ์ข… ์ ์ˆ˜ ๊ณ„์‚ฐํ•˜์—ฌ ๋ฐ˜ํ™˜ diff --git a/src/main/java/domain/Card.java b/src/main/java/domain/Card.java new file mode 100644 index 00000000..2fc3fb21 --- /dev/null +++ b/src/main/java/domain/Card.java @@ -0,0 +1,17 @@ +package domain; + +public class Card { + + private final CardSuit cardSuit; + private final CardRank cardRank; + + public Card(CardSuit cardSuit, CardRank cardRank) { + this.cardSuit = cardSuit; + this.cardRank = cardRank; + } + + @Override + public String toString() { + return this.cardRank.getValue() + this.cardSuit.getValue(); + } +} diff --git a/src/main/java/domain/CardDeck.java b/src/main/java/domain/CardDeck.java new file mode 100644 index 00000000..0b45a468 --- /dev/null +++ b/src/main/java/domain/CardDeck.java @@ -0,0 +1,38 @@ +package domain; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +public class CardDeck { + + List cardDeck; + + public CardDeck() { + generateCardDeck(); + } + + private void generateCardDeck() { + CardSuit[] suits = CardSuit.values(); + CardRank[] ranks = CardRank.values(); + + this.cardDeck = new ArrayList(); + + for (CardSuit suit : suits) { + for (CardRank rank : ranks) { + Card card = new Card(suit, rank); + this.cardDeck.add(card); + } + } + } + + public Card getCardRandomly() { + Random random = new Random(); + int randomIndex = random.nextInt(this.cardDeck.size()); + Card randomCard = this.cardDeck.get(randomIndex); + + this.cardDeck.remove(randomIndex); + + return randomCard; + } +} diff --git a/src/main/java/domain/CardRank.java b/src/main/java/domain/CardRank.java new file mode 100644 index 00000000..925f317a --- /dev/null +++ b/src/main/java/domain/CardRank.java @@ -0,0 +1,19 @@ +package domain; + +public enum CardRank { + + ACE("A"), TWO("2"), THREE("3"), FOUR("4"), FIVE("5"), + SIX("6"), SEVEN("7"), EIGHT("8"), NINE("9"), TEN("10"), + JACK("J"), QUEEN("Q"), KING("K"); + + private final String value; + + CardRank(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + +} diff --git a/src/main/java/domain/CardSuit.java b/src/main/java/domain/CardSuit.java new file mode 100644 index 00000000..ccd74510 --- /dev/null +++ b/src/main/java/domain/CardSuit.java @@ -0,0 +1,16 @@ +package domain; + +public enum CardSuit { + HEARTS("ํ•˜ํŠธ"), DIAMONDS("๋‹ค์ด์•„๋ชฌ๋“œ"), CLUBS("ํด๋กœ๋ฒ„"), SPADES("์ŠคํŽ˜์ด๋“œ"); + + private final String value; + + CardSuit(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + +} From 0bf94018b16d42ab23fe6f694bb632474aaa1aa3 Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Mon, 29 Jan 2024 15:57:07 +0900 Subject: [PATCH 12/48] =?UTF-8?q?=ED=94=8C=EB=A0=88=EC=9D=B4=EC=96=B4=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=83=9D=EC=84=B1=EA=B8=B0=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/domain/PlayerListGenerator.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/domain/PlayerListGenerator.java b/src/main/java/domain/PlayerListGenerator.java index 9adc7b44..e436c240 100644 --- a/src/main/java/domain/PlayerListGenerator.java +++ b/src/main/java/domain/PlayerListGenerator.java @@ -3,16 +3,19 @@ import java.util.ArrayList; import java.util.List; -public class PlayerList { +public class PlayerListGenerator { private List playerList; - public PlayerList() { - this.playerList = new ArrayList(); + public PlayerListGenerator(String playerNameStr) { + generatePlayerList(playerNameStr); } - public void generatePlayerList(String playerNameStr) { + private void generatePlayerList(String playerNameStr) { String[] playerNameList = playerNameStr.split(","); validateDuplicatedPlayerName(playerNameList); + + this.playerList = new ArrayList(); + for (String playerName : playerNameList) { Player player = new Player(playerName.trim()); this.playerList.add(player); From 87cb353f95f6b98ee93911b9c898d82509e42a7a Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Mon, 29 Jan 2024 16:20:08 +0900 Subject: [PATCH 13/48] =?UTF-8?q?README.md:=20=EC=B0=B8=EA=B0=80=EC=9E=90?= =?UTF-8?q?=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 ++ .../java/domain/{PlayerListGenerator.java => PlayerList.java} | 0 2 files changed, 2 insertions(+) rename src/main/java/domain/{PlayerListGenerator.java => PlayerList.java} (100%) diff --git a/README.md b/README.md index 8a631e7b..da6a4edb 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,8 @@ - [x] ๋”œ๋Ÿฌ(์ฐธ๊ฐ€์ž ์ƒ์†) +- [ ] ์ฐธ๊ฐ€์ž ๋ฆฌ์ŠคํŠธ: ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ ํ•จ๊ป˜ ์ €์žฅํ•˜๋Š” ๋ฆฌ์ŠคํŠธ + - [ ] ์นด๋“œ ๋ฐฐ๋ถ„ - [ ] ๊ฒŒ์ž„ ์‹œ์ž‘ ์‹œ ์นด๋“œ 2์žฅ ์”ฉ ์ฐธ๊ฐ€์ž๋“ค์— ์นด๋“œ๋ฑ์—์„œ ์ถ”์ถœํ•˜์—ฌ ๋ฐฐ๋ถ„ - [ ] ํ”Œ๋ ˆ์ด์–ด์— ์นด๋“œ 1์žฅ ์นด๋“œ๋ฑ์—์„œ ์ถ”์ถœํ•˜์—ฌ ๋ฐฐ๋ถ„ diff --git a/src/main/java/domain/PlayerListGenerator.java b/src/main/java/domain/PlayerList.java similarity index 100% rename from src/main/java/domain/PlayerListGenerator.java rename to src/main/java/domain/PlayerList.java From 6d63bc64b0c44a0bc3bccd3321e7b68a2af8490f Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Mon, 29 Jan 2024 16:22:17 +0900 Subject: [PATCH 14/48] =?UTF-8?q?=EC=B0=B8=EA=B0=80=EC=9E=90=20=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EA=B8=B0=EB=8A=A5=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 7 ++++--- src/main/java/domain/ParticipantList.java | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 src/main/java/domain/ParticipantList.java diff --git a/README.md b/README.md index da6a4edb..f62fc0ac 100644 --- a/README.md +++ b/README.md @@ -38,14 +38,15 @@ - [x] ๋”œ๋Ÿฌ(์ฐธ๊ฐ€์ž ์ƒ์†) -- [ ] ์ฐธ๊ฐ€์ž ๋ฆฌ์ŠคํŠธ: ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ ํ•จ๊ป˜ ์ €์žฅํ•˜๋Š” ๋ฆฌ์ŠคํŠธ - +- [x] ์ฐธ๊ฐ€์ž ๋ฆฌ์ŠคํŠธ: ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ ํ•จ๊ป˜ ์ €์žฅํ•˜๋Š” ๋ฆฌ์ŠคํŠธ + - [x] ์ฐธ๊ฐ€์ž ๋ฆฌ์ŠคํŠธ ๋ฐ˜ํ™˜ + - [ ] ์นด๋“œ ๋ฐฐ๋ถ„ - [ ] ๊ฒŒ์ž„ ์‹œ์ž‘ ์‹œ ์นด๋“œ 2์žฅ ์”ฉ ์ฐธ๊ฐ€์ž๋“ค์— ์นด๋“œ๋ฑ์—์„œ ์ถ”์ถœํ•˜์—ฌ ๋ฐฐ๋ถ„ - [ ] ํ”Œ๋ ˆ์ด์–ด์— ์นด๋“œ 1์žฅ ์นด๋“œ๋ฑ์—์„œ ์ถ”์ถœํ•˜์—ฌ ๋ฐฐ๋ถ„ - [ ] ๋”œ๋Ÿฌ์— ์นด๋“œ 1์žฅ ์นด๋“œ๋ฑ์—์„œ ์ถ”์ถœํ•˜์—ฌ ๋ฐฐ๋ถ„ -- [ ] ์ฐธ๊ฐ€์ž ์นด๋“œ ๋ฆฌ์ŠคํŠธ: ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๋ฐฐ๋ถ„ ๋ฐ›์€ ์นด๋“œ๋“ค ๋‹ด๋Š” ๋ฆฌ์ŠคํŠธ +- [ ] ์นด๋“œ ๋ฆฌ์ŠคํŠธ: ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๋ฐฐ๋ถ„ ๋ฐ›์€ ์นด๋“œ๋“ค ๋‹ด๋Š” ๋ฆฌ์ŠคํŠธ - [ ] ์นด๋“œ ๋ฆฌ์ŠคํŠธ์— ์นด๋“œ ์ถ”๊ฐ€ - [x] ์นด๋“œ ์‹ฌ๋ณผ ์ƒ์ˆ˜(ํ•˜ํŠธ~์ŠคํŽ˜์ด๋“œ) diff --git a/src/main/java/domain/ParticipantList.java b/src/main/java/domain/ParticipantList.java new file mode 100644 index 00000000..dabc0025 --- /dev/null +++ b/src/main/java/domain/ParticipantList.java @@ -0,0 +1,23 @@ +package domain; + +import java.util.ArrayList; +import java.util.List; + +public class ParticipantList { + + List participantList; + Dealer dealer; + PlayerList playerList; + + public ParticipantList(Dealer dealer, PlayerList playerList) { + this.dealer = dealer; + this.playerList = playerList; + } + + public List getParticipantList() { + this.participantList = new ArrayList(playerList.getPlayerList()); + this.participantList.add(dealer); + return this.participantList; + } + +} From e320bfb3ed3e9aab62ab118e3448245805671458 Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Mon, 29 Jan 2024 16:33:28 +0900 Subject: [PATCH 15/48] =?UTF-8?q?=EC=B9=B4=EB=93=9C=EB=A6=AC=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EA=B8=B0=EB=8A=A5=20=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 ++--- src/main/java/domain/{ => carddeck}/Card.java | 0 .../java/domain/{ => carddeck}/CardDeck.java | 0 .../java/domain/{ => carddeck}/CardRank.java | 0 .../java/domain/{ => carddeck}/CardSuit.java | 0 .../java/domain/participant/CardList.java | 23 +++++++++++++++++++ .../java/domain/{ => participant}/Dealer.java | 0 .../domain/{ => participant}/Participant.java | 0 .../{ => participant}/ParticipantList.java | 0 .../java/domain/{ => participant}/Player.java | 0 .../domain/{ => participant}/PlayerList.java | 4 ++-- 11 files changed, 28 insertions(+), 5 deletions(-) rename src/main/java/domain/{ => carddeck}/Card.java (100%) rename src/main/java/domain/{ => carddeck}/CardDeck.java (100%) rename src/main/java/domain/{ => carddeck}/CardRank.java (100%) rename src/main/java/domain/{ => carddeck}/CardSuit.java (100%) create mode 100644 src/main/java/domain/participant/CardList.java rename src/main/java/domain/{ => participant}/Dealer.java (100%) rename src/main/java/domain/{ => participant}/Participant.java (100%) rename src/main/java/domain/{ => participant}/ParticipantList.java (100%) rename src/main/java/domain/{ => participant}/Player.java (100%) rename src/main/java/domain/{ => participant}/PlayerList.java (92%) diff --git a/README.md b/README.md index f62fc0ac..73e7f436 100644 --- a/README.md +++ b/README.md @@ -40,14 +40,14 @@ - [x] ์ฐธ๊ฐ€์ž ๋ฆฌ์ŠคํŠธ: ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ ํ•จ๊ป˜ ์ €์žฅํ•˜๋Š” ๋ฆฌ์ŠคํŠธ - [x] ์ฐธ๊ฐ€์ž ๋ฆฌ์ŠคํŠธ ๋ฐ˜ํ™˜ - + - [ ] ์นด๋“œ ๋ฐฐ๋ถ„ - [ ] ๊ฒŒ์ž„ ์‹œ์ž‘ ์‹œ ์นด๋“œ 2์žฅ ์”ฉ ์ฐธ๊ฐ€์ž๋“ค์— ์นด๋“œ๋ฑ์—์„œ ์ถ”์ถœํ•˜์—ฌ ๋ฐฐ๋ถ„ - [ ] ํ”Œ๋ ˆ์ด์–ด์— ์นด๋“œ 1์žฅ ์นด๋“œ๋ฑ์—์„œ ์ถ”์ถœํ•˜์—ฌ ๋ฐฐ๋ถ„ - [ ] ๋”œ๋Ÿฌ์— ์นด๋“œ 1์žฅ ์นด๋“œ๋ฑ์—์„œ ์ถ”์ถœํ•˜์—ฌ ๋ฐฐ๋ถ„ -- [ ] ์นด๋“œ ๋ฆฌ์ŠคํŠธ: ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๋ฐฐ๋ถ„ ๋ฐ›์€ ์นด๋“œ๋“ค ๋‹ด๋Š” ๋ฆฌ์ŠคํŠธ - - [ ] ์นด๋“œ ๋ฆฌ์ŠคํŠธ์— ์นด๋“œ ์ถ”๊ฐ€ +- [x] ์นด๋“œ ๋ฆฌ์ŠคํŠธ: ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๋ฐฐ๋ถ„ ๋ฐ›์€ ์นด๋“œ๋“ค ๋‹ด๋Š” ๋ฆฌ์ŠคํŠธ + - [x] ์นด๋“œ ๋ฆฌ์ŠคํŠธ์— ์นด๋“œ ์ถ”๊ฐ€ - [x] ์นด๋“œ ์‹ฌ๋ณผ ์ƒ์ˆ˜(ํ•˜ํŠธ~์ŠคํŽ˜์ด๋“œ) diff --git a/src/main/java/domain/Card.java b/src/main/java/domain/carddeck/Card.java similarity index 100% rename from src/main/java/domain/Card.java rename to src/main/java/domain/carddeck/Card.java diff --git a/src/main/java/domain/CardDeck.java b/src/main/java/domain/carddeck/CardDeck.java similarity index 100% rename from src/main/java/domain/CardDeck.java rename to src/main/java/domain/carddeck/CardDeck.java diff --git a/src/main/java/domain/CardRank.java b/src/main/java/domain/carddeck/CardRank.java similarity index 100% rename from src/main/java/domain/CardRank.java rename to src/main/java/domain/carddeck/CardRank.java diff --git a/src/main/java/domain/CardSuit.java b/src/main/java/domain/carddeck/CardSuit.java similarity index 100% rename from src/main/java/domain/CardSuit.java rename to src/main/java/domain/carddeck/CardSuit.java diff --git a/src/main/java/domain/participant/CardList.java b/src/main/java/domain/participant/CardList.java new file mode 100644 index 00000000..e90a3b26 --- /dev/null +++ b/src/main/java/domain/participant/CardList.java @@ -0,0 +1,23 @@ +package domain.participant; + +import domain.carddeck.Card; + +import java.util.ArrayList; +import java.util.List; + +public class CardList { + + List cardList; + + public CardList() { + this.cardList = new ArrayList(); + } + + public void addCard(Card card) { + this.cardList.add(card); + } + + public List getCardList() { + return this.cardList; + } +} diff --git a/src/main/java/domain/Dealer.java b/src/main/java/domain/participant/Dealer.java similarity index 100% rename from src/main/java/domain/Dealer.java rename to src/main/java/domain/participant/Dealer.java diff --git a/src/main/java/domain/Participant.java b/src/main/java/domain/participant/Participant.java similarity index 100% rename from src/main/java/domain/Participant.java rename to src/main/java/domain/participant/Participant.java diff --git a/src/main/java/domain/ParticipantList.java b/src/main/java/domain/participant/ParticipantList.java similarity index 100% rename from src/main/java/domain/ParticipantList.java rename to src/main/java/domain/participant/ParticipantList.java diff --git a/src/main/java/domain/Player.java b/src/main/java/domain/participant/Player.java similarity index 100% rename from src/main/java/domain/Player.java rename to src/main/java/domain/participant/Player.java diff --git a/src/main/java/domain/PlayerList.java b/src/main/java/domain/participant/PlayerList.java similarity index 92% rename from src/main/java/domain/PlayerList.java rename to src/main/java/domain/participant/PlayerList.java index e436c240..0fe98323 100644 --- a/src/main/java/domain/PlayerList.java +++ b/src/main/java/domain/participant/PlayerList.java @@ -3,10 +3,10 @@ import java.util.ArrayList; import java.util.List; -public class PlayerListGenerator { +public class PlayerList { private List playerList; - public PlayerListGenerator(String playerNameStr) { + public PlayerList(String playerNameStr) { generatePlayerList(playerNameStr); } From 4f14501edd3e40b47d7348412521910265603e9d Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Mon, 29 Jan 2024 16:34:06 +0900 Subject: [PATCH 16/48] =?UTF-8?q?=EC=A0=84=EC=B2=B4=20=ED=8F=B4=EB=8D=94?= =?UTF-8?q?=20=EA=B5=AC=EC=A1=B0=20=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=83=9D=EC=84=B1=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- md | 0 src/main/java/application.java | 6 ++++++ src/main/java/controller/gameManager.java | 4 ++++ src/main/java/domain/CalculateScore.java | 4 ++++ src/main/java/domain/CardDistributor.java | 4 ++++ src/main/java/domain/ResultEvaluator.java | 4 ++++ src/main/java/domain/carddeck/Card.java | 2 +- src/main/java/domain/carddeck/CardDeck.java | 2 +- src/main/java/domain/carddeck/CardRank.java | 2 +- src/main/java/domain/carddeck/CardSuit.java | 2 +- src/main/java/domain/participant/Dealer.java | 2 +- src/main/java/domain/participant/Participant.java | 2 +- src/main/java/domain/participant/ParticipantList.java | 2 +- src/main/java/domain/participant/Player.java | 2 +- src/main/java/domain/participant/PlayerList.java | 2 +- src/main/java/view/outputview/ResultView.java | 4 ++++ src/test/java/test.java | 2 ++ 17 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 md create mode 100644 src/main/java/application.java create mode 100644 src/main/java/controller/gameManager.java create mode 100644 src/main/java/domain/CalculateScore.java create mode 100644 src/main/java/domain/CardDistributor.java create mode 100644 src/main/java/domain/ResultEvaluator.java create mode 100644 src/main/java/view/outputview/ResultView.java create mode 100644 src/test/java/test.java diff --git a/md b/md new file mode 100644 index 00000000..e69de29b diff --git a/src/main/java/application.java b/src/main/java/application.java new file mode 100644 index 00000000..da1d3d8c --- /dev/null +++ b/src/main/java/application.java @@ -0,0 +1,6 @@ +public class application { + + public static void main(String[] args) { + + } +} diff --git a/src/main/java/controller/gameManager.java b/src/main/java/controller/gameManager.java new file mode 100644 index 00000000..d09a430b --- /dev/null +++ b/src/main/java/controller/gameManager.java @@ -0,0 +1,4 @@ +package controller; + +public class gameManager { +} diff --git a/src/main/java/domain/CalculateScore.java b/src/main/java/domain/CalculateScore.java new file mode 100644 index 00000000..0b9c5caa --- /dev/null +++ b/src/main/java/domain/CalculateScore.java @@ -0,0 +1,4 @@ +package domain; + +public class CalculateScore { +} diff --git a/src/main/java/domain/CardDistributor.java b/src/main/java/domain/CardDistributor.java new file mode 100644 index 00000000..66002bbe --- /dev/null +++ b/src/main/java/domain/CardDistributor.java @@ -0,0 +1,4 @@ +package domain; + +public class CardDistributor { +} diff --git a/src/main/java/domain/ResultEvaluator.java b/src/main/java/domain/ResultEvaluator.java new file mode 100644 index 00000000..c5465dac --- /dev/null +++ b/src/main/java/domain/ResultEvaluator.java @@ -0,0 +1,4 @@ +package domain; + +public class ResultEvaluator { +} diff --git a/src/main/java/domain/carddeck/Card.java b/src/main/java/domain/carddeck/Card.java index 2fc3fb21..86c11e35 100644 --- a/src/main/java/domain/carddeck/Card.java +++ b/src/main/java/domain/carddeck/Card.java @@ -1,4 +1,4 @@ -package domain; +package domain.carddeck; public class Card { diff --git a/src/main/java/domain/carddeck/CardDeck.java b/src/main/java/domain/carddeck/CardDeck.java index 0b45a468..92321ebf 100644 --- a/src/main/java/domain/carddeck/CardDeck.java +++ b/src/main/java/domain/carddeck/CardDeck.java @@ -1,4 +1,4 @@ -package domain; +package domain.carddeck; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/domain/carddeck/CardRank.java b/src/main/java/domain/carddeck/CardRank.java index 925f317a..da2d1fd8 100644 --- a/src/main/java/domain/carddeck/CardRank.java +++ b/src/main/java/domain/carddeck/CardRank.java @@ -1,4 +1,4 @@ -package domain; +package domain.carddeck; public enum CardRank { diff --git a/src/main/java/domain/carddeck/CardSuit.java b/src/main/java/domain/carddeck/CardSuit.java index ccd74510..0fe9007f 100644 --- a/src/main/java/domain/carddeck/CardSuit.java +++ b/src/main/java/domain/carddeck/CardSuit.java @@ -1,4 +1,4 @@ -package domain; +package domain.carddeck; public enum CardSuit { HEARTS("ํ•˜ํŠธ"), DIAMONDS("๋‹ค์ด์•„๋ชฌ๋“œ"), CLUBS("ํด๋กœ๋ฒ„"), SPADES("์ŠคํŽ˜์ด๋“œ"); diff --git a/src/main/java/domain/participant/Dealer.java b/src/main/java/domain/participant/Dealer.java index ebe07f2f..4e9c5452 100644 --- a/src/main/java/domain/participant/Dealer.java +++ b/src/main/java/domain/participant/Dealer.java @@ -1,4 +1,4 @@ -package domain; +package domain.participant; public class Dealer extends Participant{ diff --git a/src/main/java/domain/participant/Participant.java b/src/main/java/domain/participant/Participant.java index c1b42f83..1afb4aab 100644 --- a/src/main/java/domain/participant/Participant.java +++ b/src/main/java/domain/participant/Participant.java @@ -1,4 +1,4 @@ -package domain; +package domain.participant; public class Participant { private String name; diff --git a/src/main/java/domain/participant/ParticipantList.java b/src/main/java/domain/participant/ParticipantList.java index dabc0025..b86e15bd 100644 --- a/src/main/java/domain/participant/ParticipantList.java +++ b/src/main/java/domain/participant/ParticipantList.java @@ -1,4 +1,4 @@ -package domain; +package domain.participant; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/domain/participant/Player.java b/src/main/java/domain/participant/Player.java index a976929f..f1c0eafe 100644 --- a/src/main/java/domain/participant/Player.java +++ b/src/main/java/domain/participant/Player.java @@ -1,4 +1,4 @@ -package domain; +package domain.participant; public class Player extends Participant{ public Player(String name) { diff --git a/src/main/java/domain/participant/PlayerList.java b/src/main/java/domain/participant/PlayerList.java index 0fe98323..ee7111bf 100644 --- a/src/main/java/domain/participant/PlayerList.java +++ b/src/main/java/domain/participant/PlayerList.java @@ -1,4 +1,4 @@ -package domain; +package domain.participant; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/view/outputview/ResultView.java b/src/main/java/view/outputview/ResultView.java new file mode 100644 index 00000000..32d8d511 --- /dev/null +++ b/src/main/java/view/outputview/ResultView.java @@ -0,0 +1,4 @@ +package view.outputview; + +public class ResultView { +} diff --git a/src/test/java/test.java b/src/test/java/test.java new file mode 100644 index 00000000..53ba7f61 --- /dev/null +++ b/src/test/java/test.java @@ -0,0 +1,2 @@ +public class test { +} From ad7023577c701197d929e95a4461115ee25e277b Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Mon, 29 Jan 2024 19:14:43 +0900 Subject: [PATCH 17/48] =?UTF-8?q?=EC=B9=B4=EB=93=9C=20=EB=B0=B0=EB=B6=84?= =?UTF-8?q?=20=EA=B8=B0=EB=8A=A5=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 15 +++++++---- src/main/java/application.java | 4 +++ src/main/java/domain/CardDistributor.java | 25 +++++++++++++++++++ .../domain/participant/ParticipantList.java | 3 ++- src/main/java/view/outputview/OutputView.java | 4 +++ 5 files changed, 45 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 73e7f436..a7d29255 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,8 @@ ## domain +### participant + - [x] ์ฐธ๊ฐ€์ž(ํด๋ž˜์Šค) - [x] ํ”Œ๋ ˆ์ด์–ด(์ฐธ๊ฐ€์ž ์ƒ์†) @@ -41,14 +43,11 @@ - [x] ์ฐธ๊ฐ€์ž ๋ฆฌ์ŠคํŠธ: ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ ํ•จ๊ป˜ ์ €์žฅํ•˜๋Š” ๋ฆฌ์ŠคํŠธ - [x] ์ฐธ๊ฐ€์ž ๋ฆฌ์ŠคํŠธ ๋ฐ˜ํ™˜ -- [ ] ์นด๋“œ ๋ฐฐ๋ถ„ - - [ ] ๊ฒŒ์ž„ ์‹œ์ž‘ ์‹œ ์นด๋“œ 2์žฅ ์”ฉ ์ฐธ๊ฐ€์ž๋“ค์— ์นด๋“œ๋ฑ์—์„œ ์ถ”์ถœํ•˜์—ฌ ๋ฐฐ๋ถ„ - - [ ] ํ”Œ๋ ˆ์ด์–ด์— ์นด๋“œ 1์žฅ ์นด๋“œ๋ฑ์—์„œ ์ถ”์ถœํ•˜์—ฌ ๋ฐฐ๋ถ„ - - [ ] ๋”œ๋Ÿฌ์— ์นด๋“œ 1์žฅ ์นด๋“œ๋ฑ์—์„œ ์ถ”์ถœํ•˜์—ฌ ๋ฐฐ๋ถ„ - - [x] ์นด๋“œ ๋ฆฌ์ŠคํŠธ: ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๋ฐฐ๋ถ„ ๋ฐ›์€ ์นด๋“œ๋“ค ๋‹ด๋Š” ๋ฆฌ์ŠคํŠธ - [x] ์นด๋“œ ๋ฆฌ์ŠคํŠธ์— ์นด๋“œ ์ถ”๊ฐ€ +### carddeck + - [x] ์นด๋“œ ์‹ฌ๋ณผ ์ƒ์ˆ˜(ํ•˜ํŠธ~์ŠคํŽ˜์ด๋“œ) - [x] ์นด๋“œ ์ˆซ์ž ์ƒ์ˆ˜(์—์ด์Šค~์žญ,ํ€ธ,ํ‚น) @@ -58,6 +57,12 @@ - [x] ์นด๋“œ๋ฑ: 52๊ฐ€์ง€ ์นด๋“œ ๋‹ด๊ณ  ์žˆ๋Š” ํ•˜๋‚˜์˜ ์นด๋“œ๋ฑ - [x] ์นด๋“œ๋ฑ์—์„œ ์นด๋“œ ์ถ”์ถœํ•˜์—ฌ ๋ฐ˜ํ™˜ +### ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง + +- [x] ์นด๋“œ ๋ฐฐ๋ถ„ + - [x] ๊ฒŒ์ž„ ์‹œ์ž‘ ์‹œ ์นด๋“œ 2์žฅ ์”ฉ ์ฐธ๊ฐ€์ž๋“ค์— ์นด๋“œ๋ฑ์—์„œ ์ถ”์ถœํ•˜์—ฌ ๋ฐฐ๋ถ„ + - [x] ํ”Œ๋ ˆ์ด์–ด์— ์นด๋“œ 1์žฅ ์นด๋“œ๋ฑ์—์„œ ์ถ”์ถœํ•˜์—ฌ ๋ฐฐ๋ถ„ + - [ ] ์ ์ˆ˜ ๊ณ„์‚ฐ - [ ] ์นด๋“œ ๋ฆฌ์ŠคํŠธ์— ์žˆ๋Š” ์นด๋“œ์— ๋Œ€ํ•ด ์ตœ์ข… ์ ์ˆ˜ ๊ณ„์‚ฐํ•˜์—ฌ ๋ฐ˜ํ™˜ diff --git a/src/main/java/application.java b/src/main/java/application.java index da1d3d8c..39d29e35 100644 --- a/src/main/java/application.java +++ b/src/main/java/application.java @@ -1,6 +1,10 @@ +import view.outputview.OutputView; + public class application { public static void main(String[] args) { + OutputView outputView = new OutputView(); + outputView.printInitialCardDistributionMessage("hello"); } } diff --git a/src/main/java/domain/CardDistributor.java b/src/main/java/domain/CardDistributor.java index 66002bbe..c93083d5 100644 --- a/src/main/java/domain/CardDistributor.java +++ b/src/main/java/domain/CardDistributor.java @@ -1,4 +1,29 @@ package domain; +import domain.carddeck.Card; +import domain.carddeck.CardDeck; +import domain.participant.Participant; +import domain.participant.ParticipantList; + +import java.util.List; + public class CardDistributor { + + private final int initialDistributionCount = 2; + + public void initialCardDistribution(CardDeck cardDeck, ParticipantList participantList) { + List participants = participantList.getParticipantList(); + for (Participant participant : participants) { + for (int i = 0; i < initialDistributionCount; i++) { + Card card = cardDeck.getCardRandomly(); + participant.getCardList().addCard(card); + } + } + } + + public void distributeOneCard(CardDeck cardDeck, Participant participant) { + Card card = cardDeck.getCardRandomly(); + participant.getCardList().addCard(card); + } + } diff --git a/src/main/java/domain/participant/ParticipantList.java b/src/main/java/domain/participant/ParticipantList.java index b86e15bd..5780bf4d 100644 --- a/src/main/java/domain/participant/ParticipantList.java +++ b/src/main/java/domain/participant/ParticipantList.java @@ -15,8 +15,9 @@ public ParticipantList(Dealer dealer, PlayerList playerList) { } public List getParticipantList() { - this.participantList = new ArrayList(playerList.getPlayerList()); + this.participantList = new ArrayList(); this.participantList.add(dealer); + participantList.addAll(playerList.getPlayerList()); return this.participantList; } diff --git a/src/main/java/view/outputview/OutputView.java b/src/main/java/view/outputview/OutputView.java index 47151c5a..39561e72 100644 --- a/src/main/java/view/outputview/OutputView.java +++ b/src/main/java/view/outputview/OutputView.java @@ -4,4 +4,8 @@ public class OutputView { public void printInputPlayerNameMessage() { System.out.println("๊ฒŒ์ž„์— ์ฐธ์—ฌํ•  ์‚ฌ๋žŒ์˜ ์ด๋ฆ„์„ ์ž…๋ ฅํ•˜์„ธ์š”.(์‰ผํ‘œ ๊ธฐ์ค€์œผ๋กœ ๋ถ„๋ฆฌ)"); } + + public void printInitialCardDistributionMessage(String value) { + System.out.printf("\n๋”œ๋Ÿฌ์™€ %s์—๊ฒŒ 2์žฅ์„ ๋‚˜๋ˆ„์—ˆ์Šต๋‹ˆ๋‹ค.", value); + } } From 43fa46ea3b6a4ec7edfaaaec54b4c528db691e3b Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Mon, 29 Jan 2024 20:30:49 +0900 Subject: [PATCH 18/48] =?UTF-8?q?README.md:=20=EC=B9=B4=EB=93=9C=20?= =?UTF-8?q?=EC=88=AB=EC=9E=90=20=EB=B3=80=ED=99=98=EA=B8=B0=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index a7d29255..7eee63db 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,9 @@ - [x] ์นด๋“œ๋ฑ: 52๊ฐ€์ง€ ์นด๋“œ ๋‹ด๊ณ  ์žˆ๋Š” ํ•˜๋‚˜์˜ ์นด๋“œ๋ฑ - [x] ์นด๋“œ๋ฑ์—์„œ ์นด๋“œ ์ถ”์ถœํ•˜์—ฌ ๋ฐ˜ํ™˜ +- [x] ์นด๋“œ ์ˆซ์ž ๋ณ€ํ™˜๊ธฐ: ๋ฌธ์ž์—ด ํ˜•ํƒœ์ธ ์นด๋“œ์˜ ์ˆซ์ž๋ฅผ ์ˆ˜๋กœ ๋ณ€ํ™˜ํ•ด์ฃผ๋Š” ๊ธฐ๋Šฅ + - [x] ๋ณ€ํ™˜๊ธฐ + ### ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง - [x] ์นด๋“œ ๋ฐฐ๋ถ„ From d7f85d744517f13638c5aa4984781f2c6bd3bd2c Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Mon, 29 Jan 2024 20:42:41 +0900 Subject: [PATCH 19/48] =?UTF-8?q?=EC=B9=B4=EB=93=9C=20=EB=B3=80=ED=99=98?= =?UTF-8?q?=EA=B8=B0=20=EA=B8=B0=EB=8A=A5,=20=EC=A0=90=EC=88=98=20?= =?UTF-8?q?=EA=B3=84=EC=82=B0=20=EA=B8=B0=EB=8A=A5=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +- src/main/java/application.java | 22 ++++++++- src/main/java/domain/CalculateScore.java | 48 ++++++++++++++++++- src/main/java/domain/carddeck/Card.java | 8 ++++ .../domain/carddeck/CardRankConverter.java | 14 ++++++ 5 files changed, 92 insertions(+), 4 deletions(-) create mode 100644 src/main/java/domain/carddeck/CardRankConverter.java diff --git a/README.md b/README.md index 7eee63db..4cc71e88 100644 --- a/README.md +++ b/README.md @@ -66,8 +66,8 @@ - [x] ๊ฒŒ์ž„ ์‹œ์ž‘ ์‹œ ์นด๋“œ 2์žฅ ์”ฉ ์ฐธ๊ฐ€์ž๋“ค์— ์นด๋“œ๋ฑ์—์„œ ์ถ”์ถœํ•˜์—ฌ ๋ฐฐ๋ถ„ - [x] ํ”Œ๋ ˆ์ด์–ด์— ์นด๋“œ 1์žฅ ์นด๋“œ๋ฑ์—์„œ ์ถ”์ถœํ•˜์—ฌ ๋ฐฐ๋ถ„ -- [ ] ์ ์ˆ˜ ๊ณ„์‚ฐ - - [ ] ์นด๋“œ ๋ฆฌ์ŠคํŠธ์— ์žˆ๋Š” ์นด๋“œ์— ๋Œ€ํ•ด ์ตœ์ข… ์ ์ˆ˜ ๊ณ„์‚ฐํ•˜์—ฌ ๋ฐ˜ํ™˜ +- [x] ์ ์ˆ˜ ๊ณ„์‚ฐ + - [x] ์นด๋“œ ๋ฆฌ์ŠคํŠธ์— ์žˆ๋Š” ์นด๋“œ์— ๋Œ€ํ•ด ์ตœ์ข… ์ ์ˆ˜ ๊ณ„์‚ฐํ•˜์—ฌ ๋ฐ˜ํ™˜ - [ ] ์ตœ์ข… ์ŠนํŒจ ํŒ๋‹จ - [ ] ์ฐธ์—ฌ์ž๋“ค ์ตœ์ข… ์ŠนํŒจ diff --git a/src/main/java/application.java b/src/main/java/application.java index 39d29e35..97efc8be 100644 --- a/src/main/java/application.java +++ b/src/main/java/application.java @@ -1,3 +1,9 @@ +import domain.CalculateScore; +import domain.CardDistributor; +import domain.carddeck.Card; +import domain.carddeck.CardDeck; +import domain.participant.Participant; +import domain.participant.PlayerList; import view.outputview.OutputView; public class application { @@ -5,6 +11,20 @@ public class application { public static void main(String[] args) { OutputView outputView = new OutputView(); - outputView.printInitialCardDistributionMessage("hello"); + Participant participant = new Participant("kim"); + CardDeck cardDeck = new CardDeck(); + + CardDistributor cardDistributor = new CardDistributor(); + + cardDistributor.distributeOneCard(cardDeck, participant); + cardDistributor.distributeOneCard(cardDeck, participant); + cardDistributor.distributeOneCard(cardDeck, participant); + + for (Card card : participant.getCardList().getCardList()) { + System.out.println(card.toString()); + } + + CalculateScore calculateScore = new CalculateScore(); + System.out.println(calculateScore.calculator(participant)); } } diff --git a/src/main/java/domain/CalculateScore.java b/src/main/java/domain/CalculateScore.java index 0b9c5caa..ec24f06b 100644 --- a/src/main/java/domain/CalculateScore.java +++ b/src/main/java/domain/CalculateScore.java @@ -1,4 +1,50 @@ package domain; +import domain.carddeck.Card; +import domain.carddeck.CardRank; +import domain.carddeck.CardRankConverter; +import domain.participant.CardList; +import domain.participant.Participant; + +import java.util.List; + public class CalculateScore { -} + + private final int targetScore = 21; + private CardRankConverter cardRankConverter = new CardRankConverter(); + + + public int calculator(Participant participant) { + int sumExceptAce = calculatorExceptAce(participant); + return calculatorContainsAce(participant, sumExceptAce); + } + + private int calculatorExceptAce(Participant participant) { + int sumExceptAce = 0; + CardList cardList = participant.getCardList(); + for (Card card : cardList.getCardList()) { + CardRank cardRank = card.getCardRank(); + sumExceptAce += this.cardRankConverter.converter(cardRank); + } + return sumExceptAce; + } + + private int calculatorContainsAce(Participant participant, int sum) { + CardList cardList = participant.getCardList(); + for (Card card : cardList.getCardList()) { + CardRank cardRank = card.getCardRank(); + if (cardRank == CardRank.ACE) { + sum = addOneOrEleven(sum); + } + } + return sum; + } + + private int addOneOrEleven(int sum) { + sum += 1; + if (sum + 11 <= targetScore) { + sum += 10; + } + return sum; + } +} \ No newline at end of file diff --git a/src/main/java/domain/carddeck/Card.java b/src/main/java/domain/carddeck/Card.java index 86c11e35..528e4b39 100644 --- a/src/main/java/domain/carddeck/Card.java +++ b/src/main/java/domain/carddeck/Card.java @@ -14,4 +14,12 @@ public Card(CardSuit cardSuit, CardRank cardRank) { public String toString() { return this.cardRank.getValue() + this.cardSuit.getValue(); } + + public CardSuit getCardSuit() { + return this.cardSuit; + } + + public CardRank getCardRank() { + return this.cardRank; + } } diff --git a/src/main/java/domain/carddeck/CardRankConverter.java b/src/main/java/domain/carddeck/CardRankConverter.java new file mode 100644 index 00000000..3ca1a1e3 --- /dev/null +++ b/src/main/java/domain/carddeck/CardRankConverter.java @@ -0,0 +1,14 @@ +package domain.carddeck; + +public class CardRankConverter { + + public int converter(CardRank cardRank) { + if ((cardRank == CardRank.JACK) || (cardRank == CardRank.QUEEN) || (cardRank == CardRank.KING)) { + return 10; + } + if (cardRank != CardRank.ACE) { + return Integer.parseInt(cardRank.getValue()); + } + return 0; + } +} From 5a0dcbab2c1baa5c96f825765c0b9761b8b5f1c9 Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Mon, 29 Jan 2024 21:31:25 +0900 Subject: [PATCH 20/48] =?UTF-8?q?21=20=EC=83=81=EC=88=98=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/domain/CalculateScore.java | 8 +++++--- src/main/java/domain/ResultEvaluator.java | 9 +++++++++ src/main/java/domain/constants/Constant.java | 7 +++++++ src/main/java/domain/participant/CardList.java | 11 ++++++++++- 4 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 src/main/java/domain/constants/Constant.java diff --git a/src/main/java/domain/CalculateScore.java b/src/main/java/domain/CalculateScore.java index ec24f06b..768f61c1 100644 --- a/src/main/java/domain/CalculateScore.java +++ b/src/main/java/domain/CalculateScore.java @@ -3,6 +3,7 @@ import domain.carddeck.Card; import domain.carddeck.CardRank; import domain.carddeck.CardRankConverter; +import domain.constants.Constant; import domain.participant.CardList; import domain.participant.Participant; @@ -10,13 +11,14 @@ public class CalculateScore { - private final int targetScore = 21; private CardRankConverter cardRankConverter = new CardRankConverter(); public int calculator(Participant participant) { int sumExceptAce = calculatorExceptAce(participant); - return calculatorContainsAce(participant, sumExceptAce); + int sum = calculatorContainsAce(participant, sumExceptAce); + participant.getCardList().setScore(sum); + return sum; } private int calculatorExceptAce(Participant participant) { @@ -42,7 +44,7 @@ private int calculatorContainsAce(Participant participant, int sum) { private int addOneOrEleven(int sum) { sum += 1; - if (sum + 11 <= targetScore) { + if (sum + 11 <= Constant.TARGET_SCORE) { sum += 10; } return sum; diff --git a/src/main/java/domain/ResultEvaluator.java b/src/main/java/domain/ResultEvaluator.java index c5465dac..b4f7a724 100644 --- a/src/main/java/domain/ResultEvaluator.java +++ b/src/main/java/domain/ResultEvaluator.java @@ -1,4 +1,13 @@ package domain; +import domain.participant.Dealer; +import domain.participant.Player; + public class ResultEvaluator { + + public void evaluator(Dealer dealer, Player player) { + int dealerScore = dealer.getCardList().getScore(); + int playerScore = player.getCardList().getScore(); + } + } diff --git a/src/main/java/domain/constants/Constant.java b/src/main/java/domain/constants/Constant.java new file mode 100644 index 00000000..69f242f3 --- /dev/null +++ b/src/main/java/domain/constants/Constant.java @@ -0,0 +1,7 @@ +package domain.constants; + +public class Constant { + + public static final int TARGET_SCORE = 21; + +} diff --git a/src/main/java/domain/participant/CardList.java b/src/main/java/domain/participant/CardList.java index e90a3b26..8a3cb0e5 100644 --- a/src/main/java/domain/participant/CardList.java +++ b/src/main/java/domain/participant/CardList.java @@ -7,7 +7,8 @@ public class CardList { - List cardList; + private List cardList; + private int score; public CardList() { this.cardList = new ArrayList(); @@ -20,4 +21,12 @@ public void addCard(Card card) { public List getCardList() { return this.cardList; } + + public void setScore(int score) { + this.score = score; + } + + public int getScore() { + return this.score; + } } From 6e6be79b46e58251d5a25f46c9ec59971bb5fda8 Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Fri, 2 Feb 2024 17:51:08 +0900 Subject: [PATCH 21/48] =?UTF-8?q?README.md=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 58 ++++------- .../{application.java => Application.java} | 0 src/main/java/{domain => }/carddeck/Card.java | 0 .../java/{domain => }/carddeck/CardDeck.java | 12 +-- src/main/java/carddeck/CardRank.java | 25 +++++ .../java/{domain => }/carddeck/CardSuit.java | 0 .../java/{domain => }/constants/Constant.java | 0 .../{gameManager.java => GameManager.java} | 0 src/main/java/domain/CalculateScore.java | 52 ---------- src/main/java/domain/CardDistributor.java | 29 ------ src/main/java/domain/DealerWinChecker.java | 25 +++++ src/main/java/domain/ResultEvaluator.java | 13 --- src/main/java/domain/ScoreCalculator.java | 6 ++ src/main/java/domain/carddeck/CardRank.java | 19 ---- .../domain/carddeck/CardRankConverter.java | 14 --- .../domain/participant/ParticipantList.java | 24 ----- .../java/domain/participant/PlayerList.java | 39 -------- .../{domain => }/participant/CardList.java | 1 - .../java/{domain => }/participant/Dealer.java | 0 .../{domain => }/participant/Participant.java | 0 .../java/{domain => }/participant/Player.java | 0 src/main/java/view/InputView.java | 40 ++++++++ src/main/java/view/OutputView.java | 98 +++++++++++++++++++ src/main/java/view/inputview/InputView.java | 13 --- src/main/java/view/outputview/OutputView.java | 11 --- src/main/java/view/outputview/ResultView.java | 4 - 26 files changed, 217 insertions(+), 266 deletions(-) rename src/main/java/{application.java => Application.java} (100%) rename src/main/java/{domain => }/carddeck/Card.java (100%) rename src/main/java/{domain => }/carddeck/CardDeck.java (69%) create mode 100644 src/main/java/carddeck/CardRank.java rename src/main/java/{domain => }/carddeck/CardSuit.java (100%) rename src/main/java/{domain => }/constants/Constant.java (100%) rename src/main/java/controller/{gameManager.java => GameManager.java} (100%) delete mode 100644 src/main/java/domain/CalculateScore.java delete mode 100644 src/main/java/domain/CardDistributor.java create mode 100644 src/main/java/domain/DealerWinChecker.java delete mode 100644 src/main/java/domain/ResultEvaluator.java create mode 100644 src/main/java/domain/ScoreCalculator.java delete mode 100644 src/main/java/domain/carddeck/CardRank.java delete mode 100644 src/main/java/domain/carddeck/CardRankConverter.java delete mode 100644 src/main/java/domain/participant/ParticipantList.java delete mode 100644 src/main/java/domain/participant/PlayerList.java rename src/main/java/{domain => }/participant/CardList.java (95%) rename src/main/java/{domain => }/participant/Dealer.java (100%) rename src/main/java/{domain => }/participant/Participant.java (100%) rename src/main/java/{domain => }/participant/Player.java (100%) create mode 100644 src/main/java/view/InputView.java create mode 100644 src/main/java/view/OutputView.java delete mode 100644 src/main/java/view/inputview/InputView.java delete mode 100644 src/main/java/view/outputview/OutputView.java delete mode 100644 src/main/java/view/outputview/ResultView.java diff --git a/README.md b/README.md index 4cc71e88..e293b9a2 100644 --- a/README.md +++ b/README.md @@ -4,24 +4,19 @@ ## view -### inputView - - [ ] ์ž…๋ ฅ - - [x] ํ”Œ๋ ˆ์ด์–ด ๋ชฉ๋ก ์ž…๋ ฅ + - [ ] ํ”Œ๋ ˆ์ด์–ด ๋ชฉ๋ก ์ž…๋ ฅ - [ ] ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์นด๋“œ๋ฅผ ๋ฐ›์„์ง€ ์—ฌ๋ถ€(y/n) ์ž…๋ ฅ - -### outputView + - [ ] y ๋˜๋Š” n์ธ์ง€ ๊ฒ€์ฆ - [ ] ์ถœ๋ ฅ - - [x] ํ”Œ๋ ˆ์ด์–ด ์ด๋ฆ„ ์ž…๋ ฅํ•˜๊ธฐ ๋ฌธ๊ตฌ + - [ ] ํ”Œ๋ ˆ์ด์–ด ์ด๋ฆ„ ์ž…๋ ฅํ•˜๊ธฐ ๋ฌธ๊ตฌ - [ ] ๊ฒŒ์ž„ ์‹œ์ž‘ ์‹œ ์นด๋“œ 2์žฅ ๋ฐฐ๋ถ„์— ๋Œ€ํ•œ ๋ฌธ๊ตฌ - - [ ] ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์นด๋“œ๋ฅผ ๋ฐ›์„์ง€ ์—ฌ๋ถ€(y/n) ๋ฌป๋Š” ๋ฌธ๊ตฌ - [ ] ์ฐธ์—ฌ์ž ์นด๋“œ ๋ฆฌ์ŠคํŠธ ๋‚ด์˜ ์นด๋“œ ์ถœ๋ ฅ (jason์นด๋“œ: 7ํด๋กœ๋ฒ„, K์ŠคํŽ˜์ด๋“œ) + - [ ] ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์นด๋“œ๋ฅผ ๋ฐ›์„์ง€ ์—ฌ๋ถ€(y/n) ๋ฌป๋Š” ๋ฌธ๊ตฌ - [ ] ๋”œ๋Ÿฌ ์นด๋“œ ์ถ”๊ฐ€์ ์œผ๋กœ ๋ฐ›์•˜์„ ๋•Œ ๋ฌธ๊ตฌ - -- [ ] ๊ฒฐ๊ณผ ์ถœ๋ ฅ - - [ ] ์ ์ˆ˜ ๊ณ„์‚ฐ ๊ฒฐ๊ณผ ์ถœ๋ ฅ - - [ ] ์ตœ์ข… ์ŠนํŒจ ์ถœ๋ ฅ + - [ ] ์นด๋“œ ์ ์ˆ˜ ๊ณ„์‚ฐ ๊ฒฐ๊ณผ ์ถœ๋ ฅ + - [ ] ์ตœ์ข… ์ŠนํŒจ ๊ฒฐ๊ณผ ์ถœ๋ ฅ
@@ -33,44 +28,33 @@ - [x] ํ”Œ๋ ˆ์ด์–ด(์ฐธ๊ฐ€์ž ์ƒ์†) -- [x] ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ - - [x] ํ”Œ๋ ˆ์ด์–ด ์ด๋ฆ„ ๋ชฉ๋ก ๋ฐ›์•„์„œ ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ ์ƒ์„ฑ - - [x] ํ”Œ๋ ˆ์ด์–ด ์ด๋ฆ„ ์ค‘๋ณต ์˜ˆ์™ธ์ฒ˜๋ฆฌ - - [x] ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ ๋ฐ˜ํ™˜ - - [x] ๋”œ๋Ÿฌ(์ฐธ๊ฐ€์ž ์ƒ์†) -- [x] ์ฐธ๊ฐ€์ž ๋ฆฌ์ŠคํŠธ: ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ ํ•จ๊ป˜ ์ €์žฅํ•˜๋Š” ๋ฆฌ์ŠคํŠธ - - [x] ์ฐธ๊ฐ€์ž ๋ฆฌ์ŠคํŠธ ๋ฐ˜ํ™˜ +- [ ] ์ด๋ฆ„: ์ฐธ๊ฐ€์ž์˜ ํ•„๋“œ + +- [ ] ์ด๋ฆ„ ๊ฒ€์ฆ - [x] ์นด๋“œ ๋ฆฌ์ŠคํŠธ: ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๋ฐฐ๋ถ„ ๋ฐ›์€ ์นด๋“œ๋“ค ๋‹ด๋Š” ๋ฆฌ์ŠคํŠธ - - [x] ์นด๋“œ ๋ฆฌ์ŠคํŠธ์— ์นด๋“œ ์ถ”๊ฐ€ ### carddeck -- [x] ์นด๋“œ ์‹ฌ๋ณผ ์ƒ์ˆ˜(ํ•˜ํŠธ~์ŠคํŽ˜์ด๋“œ) +- [x] ์นด๋“œ ์‹ฌ๋ณผ(ํ•˜ํŠธ~์ŠคํŽ˜์ด๋“œ) -- [x] ์นด๋“œ ์ˆซ์ž ์ƒ์ˆ˜(์—์ด์Šค~์žญ,ํ€ธ,ํ‚น) +- [x] ์นด๋“œ ๋žญํฌ(๋žญํฌ(์—์ด์Šค~์žญ,ํ€ธ,ํ‚น)์™€ ์ˆซ์ž ๊ฐ’) -- [x] ์นด๋“œ: ์‹ฌ๋ณผ(ํ•˜ํŠธ, ์ŠคํŽ˜์ด๋“œ, ๋‹ค์ด์•„๋ชฌ๋“œ, ํด๋กœ๋ฒ„)๊ณผ ์ˆซ์ž(์—์ด์Šค~ํ‚น) ์กฐํ•ฉ์œผ๋กœ ์ด๋ฃจ์–ด์ง„ ์นด๋“œ +- [x] ์นด๋“œ: ์‹ฌ๋ณผ(ํ•˜ํŠธ, ์ŠคํŽ˜์ด๋“œ, ๋‹ค์ด์•„๋ชฌ๋“œ, ํด๋กœ๋ฒ„)๊ณผ ๋žญํฌ(์—์ด์Šค~ํ‚น) ์กฐํ•ฉ์œผ๋กœ ์ด๋ฃจ์–ด์ง„ ์นด๋“œ - [x] ์นด๋“œ๋ฑ: 52๊ฐ€์ง€ ์นด๋“œ ๋‹ด๊ณ  ์žˆ๋Š” ํ•˜๋‚˜์˜ ์นด๋“œ๋ฑ - [x] ์นด๋“œ๋ฑ์—์„œ ์นด๋“œ ์ถ”์ถœํ•˜์—ฌ ๋ฐ˜ํ™˜ -- [x] ์นด๋“œ ์ˆซ์ž ๋ณ€ํ™˜๊ธฐ: ๋ฌธ์ž์—ด ํ˜•ํƒœ์ธ ์นด๋“œ์˜ ์ˆซ์ž๋ฅผ ์ˆ˜๋กœ ๋ณ€ํ™˜ํ•ด์ฃผ๋Š” ๊ธฐ๋Šฅ - - [x] ๋ณ€ํ™˜๊ธฐ ### ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง -- [x] ์นด๋“œ ๋ฐฐ๋ถ„ - - [x] ๊ฒŒ์ž„ ์‹œ์ž‘ ์‹œ ์นด๋“œ 2์žฅ ์”ฉ ์ฐธ๊ฐ€์ž๋“ค์— ์นด๋“œ๋ฑ์—์„œ ์ถ”์ถœํ•˜์—ฌ ๋ฐฐ๋ถ„ - - [x] ํ”Œ๋ ˆ์ด์–ด์— ์นด๋“œ 1์žฅ ์นด๋“œ๋ฑ์—์„œ ์ถ”์ถœํ•˜์—ฌ ๋ฐฐ๋ถ„ +- [x] ๋ธ”๋ž™์žญ: ์นด๋“œ๋ฑ ์ƒ์„ฑ, ์ฐธ๊ฐ€์ž์— ์นด๋“œ ๋ฐฐ๋ถ„ -- [x] ์ ์ˆ˜ ๊ณ„์‚ฐ - - [x] ์นด๋“œ ๋ฆฌ์ŠคํŠธ์— ์žˆ๋Š” ์นด๋“œ์— ๋Œ€ํ•ด ์ตœ์ข… ์ ์ˆ˜ ๊ณ„์‚ฐํ•˜์—ฌ ๋ฐ˜ํ™˜ +- [x] ์นด๋“œ ์ ์ˆ˜ ๊ณ„์‚ฐ -- [ ] ์ตœ์ข… ์ŠนํŒจ ํŒ๋‹จ - - [ ] ์ฐธ์—ฌ์ž๋“ค ์ตœ์ข… ์ŠนํŒจ +- [x] ๋”œ๋Ÿฌ ์Šน๋ฆฌ ์ฑ„ํฌ
@@ -79,14 +63,6 @@ - [ ] ๊ฒŒ์ž„ ๋งค๋‹ˆ์ € - [ ] ๊ฒŒ์ž„ ์‹œ์ž‘ - [ ] ์ฐธ๊ฐ€์ž ์ƒ์„ฑ - - [ ] ์นด๋“œ ๋ฐฐ๋ถ„ + - [ ] ๋ธ”๋ž™์žญ ๊ฒŒ์ž„ ์‹œ์ž‘ - [ ] ์ ์ˆ˜ ๊ณ„์‚ฐ ๊ฒฐ๊ณผ ์ถœ๋ ฅ - - [ ] ์ตœ์ข… ์ŠนํŒจ ๊ฒฐ๊ณผ ์ถœ๋ ฅ - - [ ] ์ฐธ๊ฐ€์ž ์ƒ์„ฑ - - [ ] ํ”Œ๋ ˆ์ด์–ด ์ด๋ฆ„ ์ž…๋ ฅ ๋ฐ›๊ธฐ - - [ ] ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ ์ƒ์„ฑ - - [ ] ํ”Œ๋ ˆ์ด์–ด ์ƒ์„ฑ - - [ ] ๋”œ๋Ÿฌ ์ƒ์„ฑ - - [ ] ์นด๋“œ ๋ฐฐ๋ถ„ - - [ ] ํ”Œ๋ ˆ์ด์–ด๋“ค์—๊ฒŒ ์นด๋“œ ์ถ”๊ฐ€ ์—ฌ๋ถ€ ๋ฌป๊ธฐ (๋ชจ๋“  ํ”Œ๋ ˆ์ด์–ด์— ๋Œ€ํ•ด, ๊ฐ ํ”Œ๋ ˆ์ด์–ด ๊ทธ๋งŒ ์ถ”๊ฐ€ํ•  ๋•Œ๊นŒ์ง€) - - [ ] ๋”œ๋Ÿฌ ์นด๋“œ ํ•ฉ 16์ดํ•˜ ์‹œ ์นด๋“œ ์ถ”๊ฐ€ + - [ ] ์ตœ์ข… ์ŠนํŒจ ๊ฒฐ๊ณผ ์ถœ๋ ฅ \ No newline at end of file diff --git a/src/main/java/application.java b/src/main/java/Application.java similarity index 100% rename from src/main/java/application.java rename to src/main/java/Application.java diff --git a/src/main/java/domain/carddeck/Card.java b/src/main/java/carddeck/Card.java similarity index 100% rename from src/main/java/domain/carddeck/Card.java rename to src/main/java/carddeck/Card.java diff --git a/src/main/java/domain/carddeck/CardDeck.java b/src/main/java/carddeck/CardDeck.java similarity index 69% rename from src/main/java/domain/carddeck/CardDeck.java rename to src/main/java/carddeck/CardDeck.java index 92321ebf..7e90e2ca 100644 --- a/src/main/java/domain/carddeck/CardDeck.java +++ b/src/main/java/carddeck/CardDeck.java @@ -1,6 +1,7 @@ package domain.carddeck; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Random; @@ -24,15 +25,14 @@ private void generateCardDeck() { this.cardDeck.add(card); } } + Collections.shuffle(this.cardDeck); } - public Card getCardRandomly() { - Random random = new Random(); - int randomIndex = random.nextInt(this.cardDeck.size()); - Card randomCard = this.cardDeck.get(randomIndex); + public Card getCard() { - this.cardDeck.remove(randomIndex); + Card card = this.cardDeck.get(0); + this.cardDeck.remove(0); - return randomCard; + return card; } } diff --git a/src/main/java/carddeck/CardRank.java b/src/main/java/carddeck/CardRank.java new file mode 100644 index 00000000..e3d0fb03 --- /dev/null +++ b/src/main/java/carddeck/CardRank.java @@ -0,0 +1,25 @@ +package domain.carddeck; + +public enum CardRank { + + ACE_ONE("A", 1), ACE_ELEVEN("A", 11), 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); + + private final String rank; + private final int value; + + CardRank(String rank, int value) { + this.rank = rank; + this.value = value; + } + + public String getRank() { + return rank; + } + + public int getValue() { + return value; + } + +} diff --git a/src/main/java/domain/carddeck/CardSuit.java b/src/main/java/carddeck/CardSuit.java similarity index 100% rename from src/main/java/domain/carddeck/CardSuit.java rename to src/main/java/carddeck/CardSuit.java diff --git a/src/main/java/domain/constants/Constant.java b/src/main/java/constants/Constant.java similarity index 100% rename from src/main/java/domain/constants/Constant.java rename to src/main/java/constants/Constant.java diff --git a/src/main/java/controller/gameManager.java b/src/main/java/controller/GameManager.java similarity index 100% rename from src/main/java/controller/gameManager.java rename to src/main/java/controller/GameManager.java diff --git a/src/main/java/domain/CalculateScore.java b/src/main/java/domain/CalculateScore.java deleted file mode 100644 index 768f61c1..00000000 --- a/src/main/java/domain/CalculateScore.java +++ /dev/null @@ -1,52 +0,0 @@ -package domain; - -import domain.carddeck.Card; -import domain.carddeck.CardRank; -import domain.carddeck.CardRankConverter; -import domain.constants.Constant; -import domain.participant.CardList; -import domain.participant.Participant; - -import java.util.List; - -public class CalculateScore { - - private CardRankConverter cardRankConverter = new CardRankConverter(); - - - public int calculator(Participant participant) { - int sumExceptAce = calculatorExceptAce(participant); - int sum = calculatorContainsAce(participant, sumExceptAce); - participant.getCardList().setScore(sum); - return sum; - } - - private int calculatorExceptAce(Participant participant) { - int sumExceptAce = 0; - CardList cardList = participant.getCardList(); - for (Card card : cardList.getCardList()) { - CardRank cardRank = card.getCardRank(); - sumExceptAce += this.cardRankConverter.converter(cardRank); - } - return sumExceptAce; - } - - private int calculatorContainsAce(Participant participant, int sum) { - CardList cardList = participant.getCardList(); - for (Card card : cardList.getCardList()) { - CardRank cardRank = card.getCardRank(); - if (cardRank == CardRank.ACE) { - sum = addOneOrEleven(sum); - } - } - return sum; - } - - private int addOneOrEleven(int sum) { - sum += 1; - if (sum + 11 <= Constant.TARGET_SCORE) { - sum += 10; - } - return sum; - } -} \ No newline at end of file diff --git a/src/main/java/domain/CardDistributor.java b/src/main/java/domain/CardDistributor.java deleted file mode 100644 index c93083d5..00000000 --- a/src/main/java/domain/CardDistributor.java +++ /dev/null @@ -1,29 +0,0 @@ -package domain; - -import domain.carddeck.Card; -import domain.carddeck.CardDeck; -import domain.participant.Participant; -import domain.participant.ParticipantList; - -import java.util.List; - -public class CardDistributor { - - private final int initialDistributionCount = 2; - - public void initialCardDistribution(CardDeck cardDeck, ParticipantList participantList) { - List participants = participantList.getParticipantList(); - for (Participant participant : participants) { - for (int i = 0; i < initialDistributionCount; i++) { - Card card = cardDeck.getCardRandomly(); - participant.getCardList().addCard(card); - } - } - } - - public void distributeOneCard(CardDeck cardDeck, Participant participant) { - Card card = cardDeck.getCardRandomly(); - participant.getCardList().addCard(card); - } - -} diff --git a/src/main/java/domain/DealerWinChecker.java b/src/main/java/domain/DealerWinChecker.java new file mode 100644 index 00000000..5b39204f --- /dev/null +++ b/src/main/java/domain/DealerWinChecker.java @@ -0,0 +1,25 @@ +package domain; + +import participant.Dealer; +import participant.Participant; +import participant.Player; + +import java.util.concurrent.Delayed; + +public class WinnerChecker { + + private Dealer dealer; + private int score; + + public (Dealer dealer) { + this.dealer = dealer; + this.score = ScoreCalculator.calculateScore(dealer); + } + + public void check(Player player) { + + } + + + +} diff --git a/src/main/java/domain/ResultEvaluator.java b/src/main/java/domain/ResultEvaluator.java deleted file mode 100644 index b4f7a724..00000000 --- a/src/main/java/domain/ResultEvaluator.java +++ /dev/null @@ -1,13 +0,0 @@ -package domain; - -import domain.participant.Dealer; -import domain.participant.Player; - -public class ResultEvaluator { - - public void evaluator(Dealer dealer, Player player) { - int dealerScore = dealer.getCardList().getScore(); - int playerScore = player.getCardList().getScore(); - } - -} diff --git a/src/main/java/domain/ScoreCalculator.java b/src/main/java/domain/ScoreCalculator.java new file mode 100644 index 00000000..ee5b19af --- /dev/null +++ b/src/main/java/domain/ScoreCalculator.java @@ -0,0 +1,6 @@ +package domain; + +public class ScoreCalculator { + + +} \ No newline at end of file diff --git a/src/main/java/domain/carddeck/CardRank.java b/src/main/java/domain/carddeck/CardRank.java deleted file mode 100644 index da2d1fd8..00000000 --- a/src/main/java/domain/carddeck/CardRank.java +++ /dev/null @@ -1,19 +0,0 @@ -package domain.carddeck; - -public enum CardRank { - - ACE("A"), TWO("2"), THREE("3"), FOUR("4"), FIVE("5"), - SIX("6"), SEVEN("7"), EIGHT("8"), NINE("9"), TEN("10"), - JACK("J"), QUEEN("Q"), KING("K"); - - private final String value; - - CardRank(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - -} diff --git a/src/main/java/domain/carddeck/CardRankConverter.java b/src/main/java/domain/carddeck/CardRankConverter.java deleted file mode 100644 index 3ca1a1e3..00000000 --- a/src/main/java/domain/carddeck/CardRankConverter.java +++ /dev/null @@ -1,14 +0,0 @@ -package domain.carddeck; - -public class CardRankConverter { - - public int converter(CardRank cardRank) { - if ((cardRank == CardRank.JACK) || (cardRank == CardRank.QUEEN) || (cardRank == CardRank.KING)) { - return 10; - } - if (cardRank != CardRank.ACE) { - return Integer.parseInt(cardRank.getValue()); - } - return 0; - } -} diff --git a/src/main/java/domain/participant/ParticipantList.java b/src/main/java/domain/participant/ParticipantList.java deleted file mode 100644 index 5780bf4d..00000000 --- a/src/main/java/domain/participant/ParticipantList.java +++ /dev/null @@ -1,24 +0,0 @@ -package domain.participant; - -import java.util.ArrayList; -import java.util.List; - -public class ParticipantList { - - List participantList; - Dealer dealer; - PlayerList playerList; - - public ParticipantList(Dealer dealer, PlayerList playerList) { - this.dealer = dealer; - this.playerList = playerList; - } - - public List getParticipantList() { - this.participantList = new ArrayList(); - this.participantList.add(dealer); - participantList.addAll(playerList.getPlayerList()); - return this.participantList; - } - -} diff --git a/src/main/java/domain/participant/PlayerList.java b/src/main/java/domain/participant/PlayerList.java deleted file mode 100644 index ee7111bf..00000000 --- a/src/main/java/domain/participant/PlayerList.java +++ /dev/null @@ -1,39 +0,0 @@ -package domain.participant; - -import java.util.ArrayList; -import java.util.List; - -public class PlayerList { - private List playerList; - - public PlayerList(String playerNameStr) { - generatePlayerList(playerNameStr); - } - - private void generatePlayerList(String playerNameStr) { - String[] playerNameList = playerNameStr.split(","); - validateDuplicatedPlayerName(playerNameList); - - this.playerList = new ArrayList(); - - for (String playerName : playerNameList) { - Player player = new Player(playerName.trim()); - this.playerList.add(player); - } - } - - private void validateDuplicatedPlayerName(String[] playerNameList) { - List processedPlayerNameList = new ArrayList(); - for (String playerName : playerNameList) { - if (processedPlayerNameList.contains(playerName.trim())) { - throw new IllegalArgumentException("ํ”Œ๋ ˆ์ด์–ด ์ด๋ฆ„ ์ค‘๋ณต"); - } - processedPlayerNameList.add(playerName.trim()); - } - } - - public List getPlayerList() { - return this.playerList; - } - -} diff --git a/src/main/java/domain/participant/CardList.java b/src/main/java/participant/CardList.java similarity index 95% rename from src/main/java/domain/participant/CardList.java rename to src/main/java/participant/CardList.java index 8a3cb0e5..7c5fd3a6 100644 --- a/src/main/java/domain/participant/CardList.java +++ b/src/main/java/participant/CardList.java @@ -8,7 +8,6 @@ public class CardList { private List cardList; - private int score; public CardList() { this.cardList = new ArrayList(); diff --git a/src/main/java/domain/participant/Dealer.java b/src/main/java/participant/Dealer.java similarity index 100% rename from src/main/java/domain/participant/Dealer.java rename to src/main/java/participant/Dealer.java diff --git a/src/main/java/domain/participant/Participant.java b/src/main/java/participant/Participant.java similarity index 100% rename from src/main/java/domain/participant/Participant.java rename to src/main/java/participant/Participant.java diff --git a/src/main/java/domain/participant/Player.java b/src/main/java/participant/Player.java similarity index 100% rename from src/main/java/domain/participant/Player.java rename to src/main/java/participant/Player.java diff --git a/src/main/java/view/InputView.java b/src/main/java/view/InputView.java new file mode 100644 index 00000000..079a04b2 --- /dev/null +++ b/src/main/java/view/InputView.java @@ -0,0 +1,40 @@ +package view.inputview; + +import constants.Constant; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Scanner; + +public class InputView { + + private Scanner sc; + + public InputView() { + this.sc = new Scanner(System.in); + } + + public List inputPlayerName() { + String playerNameStr = this.sc.nextLine(); + List list = Arrays.asList(playerNameStr.split(",")); + List playerNameList = new ArrayList(); + for (String name : list) { + playerNameList.add(name.trim()); + } + return playerNameList; + } + + public String askForAdditionalCard() { + String answer = this.sc.nextLine(); + validateAnswer(answer); + return answer; + } + + private void validateAnswer(String value) { + if (!(value.equals(Constant.YES) || value.equals(Constant.NO))) { + throw new IllegalArgumentException("y ๋˜๋Š” n์„ ์ž…๋ ฅํ•˜์‹œ์˜ค."); + } + } + +} diff --git a/src/main/java/view/OutputView.java b/src/main/java/view/OutputView.java new file mode 100644 index 00000000..0f733430 --- /dev/null +++ b/src/main/java/view/OutputView.java @@ -0,0 +1,98 @@ +package view.outputview; + +import carddeck.Card; +import participant.Dealer; +import participant.Participant; +import participant.Player; + +import java.util.HashMap; +import java.util.List; + +public class OutputView { + public void printInputPlayerNameMessage() { + System.out.println("๊ฒŒ์ž„์— ์ฐธ์—ฌํ•  ์‚ฌ๋žŒ์˜ ์ด๋ฆ„์„ ์ž…๋ ฅํ•˜์„ธ์š”.(์‰ผํ‘œ ๊ธฐ์ค€์œผ๋กœ ๋ถ„๋ฆฌ)"); + } + + public void printInitialCardDistributionMessage(List names) { + StringBuilder stringBuilder = new StringBuilder(); + for (int i = 0; i < names.size(); i++) { + stringBuilder.append(names.get(i)); + if (i < names.size() - 1) { + stringBuilder.append(", "); + } + } + System.out.printf("\n๋”œ๋Ÿฌ์™€ %s์—๊ฒŒ 2์žฅ์„ ๋‚˜๋ˆ„์—ˆ์Šต๋‹ˆ๋‹ค.\n", stringBuilder); + } + + public void printParticipantCardList(Participant participant) { + List cardList = participant.getCardList(); + StringBuilder stringBuilder = new StringBuilder(); + if (participant instanceof Player) { + stringBuilder.append(participant.getName()).append("์นด๋“œ: "); + } + if (participant instanceof Dealer) { + stringBuilder.append(participant.getName()).append(": "); + } + stringBuilder.append(cardListString(cardList)); + System.out.println(stringBuilder); + } + + private StringBuilder cardListString(List cardList) { + StringBuilder stringBuilder = new StringBuilder(); + for (int i = 0; i < cardList.size(); i++) { + stringBuilder.append(cardList.get(i).toString()); + if (i < cardList.size() - 1) { + stringBuilder.append(", "); + } + } + return stringBuilder; + } + + public void printEmptyLine() { + System.out.println(); + } + + public void printAskForAdditionalCard(String name) { + System.out.printf("%s๋Š” ํ•œ์žฅ์˜ ์นด๋“œ๋ฅผ ๋” ๋ฐ›๊ฒ ์Šต๋‹ˆ๊นŒ?(์˜ˆ๋Š” y, ์•„๋‹ˆ์˜ค๋Š” n)\n", name); + } + + public void printDealerGetOneMoreCard() { + System.out.println("๋”œ๋Ÿฌ๋Š” 16์ดํ•˜๋ผ ํ•œ์žฅ์˜ ์นด๋“œ๋ฅผ ๋” ๋ฐ›์•˜์Šต๋‹ˆ๋‹ค.\n"); + } + + public void printScore(Participant participant, int score) { + List cardList = participant.getCardList(); + StringBuilder stringBuilder = new StringBuilder(); + if (participant instanceof Player) { + stringBuilder.append(participant.getName()).append("์นด๋“œ: "); + } + if (participant instanceof Dealer) { + stringBuilder.append(participant.getName()).append(" ์นด๋“œ: "); + } + stringBuilder.append(cardListString(cardList).append(" - ๊ฒฐ๊ณผ: ").append(score)); + System.out.println(stringBuilder); + } + + public void printFinalResult(List dealerResult, HashMap playerResult) { + System.out.println("## ์ตœ์ข… ์ŠนํŒจ"); + System.out.println(getDealerString(dealerResult)); + for (String name : playerResult.keySet()) { + System.out.println(name + ": " + playerResult.get(name)); + } + } + + private StringBuilder getDealerString(List dealerResult) { + StringBuilder dealerString = new StringBuilder(); + dealerString.append("๋”œ๋Ÿฌ: "); + if (dealerResult.get(0) > 0) { + dealerString.append(dealerResult.get(0)).append("์Šน "); + } + if (dealerResult.get(1) > 0) { + dealerString.append(dealerResult.get(1)).append("ํŒจ "); + } + if (dealerResult.get(2) > 0) { + dealerString.append(dealerResult.get(2)).append("๋ฌด์Šน๋ถ€"); + } + return dealerString; + } +} diff --git a/src/main/java/view/inputview/InputView.java b/src/main/java/view/inputview/InputView.java deleted file mode 100644 index 9d9b0d7e..00000000 --- a/src/main/java/view/inputview/InputView.java +++ /dev/null @@ -1,13 +0,0 @@ -package view.inputview; - -import java.util.Scanner; - -public class InputView { - - public String inputPlayerName() { - Scanner sc = new Scanner(System.in); - String playerNameStr = sc.nextLine(); - return playerNameStr; - } - -} diff --git a/src/main/java/view/outputview/OutputView.java b/src/main/java/view/outputview/OutputView.java deleted file mode 100644 index 39561e72..00000000 --- a/src/main/java/view/outputview/OutputView.java +++ /dev/null @@ -1,11 +0,0 @@ -package view.outputview; - -public class OutputView { - public void printInputPlayerNameMessage() { - System.out.println("๊ฒŒ์ž„์— ์ฐธ์—ฌํ•  ์‚ฌ๋žŒ์˜ ์ด๋ฆ„์„ ์ž…๋ ฅํ•˜์„ธ์š”.(์‰ผํ‘œ ๊ธฐ์ค€์œผ๋กœ ๋ถ„๋ฆฌ)"); - } - - public void printInitialCardDistributionMessage(String value) { - System.out.printf("\n๋”œ๋Ÿฌ์™€ %s์—๊ฒŒ 2์žฅ์„ ๋‚˜๋ˆ„์—ˆ์Šต๋‹ˆ๋‹ค.", value); - } -} diff --git a/src/main/java/view/outputview/ResultView.java b/src/main/java/view/outputview/ResultView.java deleted file mode 100644 index 32d8d511..00000000 --- a/src/main/java/view/outputview/ResultView.java +++ /dev/null @@ -1,4 +0,0 @@ -package view.outputview; - -public class ResultView { -} From c57f3537eb968de62f89f10f21961c1b1357b763 Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Fri, 2 Feb 2024 17:59:18 +0900 Subject: [PATCH 22/48] =?UTF-8?q?InputView=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 ++++---- src/main/java/view/InputView.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e293b9a2..9106c058 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,10 @@ ## view -- [ ] ์ž…๋ ฅ - - [ ] ํ”Œ๋ ˆ์ด์–ด ๋ชฉ๋ก ์ž…๋ ฅ - - [ ] ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์นด๋“œ๋ฅผ ๋ฐ›์„์ง€ ์—ฌ๋ถ€(y/n) ์ž…๋ ฅ - - [ ] y ๋˜๋Š” n์ธ์ง€ ๊ฒ€์ฆ +- [x] ์ž…๋ ฅ + - [x] ํ”Œ๋ ˆ์ด์–ด ๋ชฉ๋ก ์ž…๋ ฅ + - [x] ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์นด๋“œ๋ฅผ ๋ฐ›์„์ง€ ์—ฌ๋ถ€(y/n) ์ž…๋ ฅ + - [x] y ๋˜๋Š” n์ธ์ง€ ๊ฒ€์ฆ - [ ] ์ถœ๋ ฅ - [ ] ํ”Œ๋ ˆ์ด์–ด ์ด๋ฆ„ ์ž…๋ ฅํ•˜๊ธฐ ๋ฌธ๊ตฌ diff --git a/src/main/java/view/InputView.java b/src/main/java/view/InputView.java index 079a04b2..6c23874a 100644 --- a/src/main/java/view/InputView.java +++ b/src/main/java/view/InputView.java @@ -1,4 +1,4 @@ -package view.inputview; +package view; import constants.Constant; From 5afd4678df0b581b479352145ff3f69d7c9d614d Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Fri, 2 Feb 2024 18:00:13 +0900 Subject: [PATCH 23/48] =?UTF-8?q?OutputView=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 16 ++++++++-------- src/main/java/view/OutputView.java | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 9106c058..5f0faca4 100644 --- a/README.md +++ b/README.md @@ -9,14 +9,14 @@ - [x] ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์นด๋“œ๋ฅผ ๋ฐ›์„์ง€ ์—ฌ๋ถ€(y/n) ์ž…๋ ฅ - [x] y ๋˜๋Š” n์ธ์ง€ ๊ฒ€์ฆ -- [ ] ์ถœ๋ ฅ - - [ ] ํ”Œ๋ ˆ์ด์–ด ์ด๋ฆ„ ์ž…๋ ฅํ•˜๊ธฐ ๋ฌธ๊ตฌ - - [ ] ๊ฒŒ์ž„ ์‹œ์ž‘ ์‹œ ์นด๋“œ 2์žฅ ๋ฐฐ๋ถ„์— ๋Œ€ํ•œ ๋ฌธ๊ตฌ - - [ ] ์ฐธ์—ฌ์ž ์นด๋“œ ๋ฆฌ์ŠคํŠธ ๋‚ด์˜ ์นด๋“œ ์ถœ๋ ฅ (jason์นด๋“œ: 7ํด๋กœ๋ฒ„, K์ŠคํŽ˜์ด๋“œ) - - [ ] ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์นด๋“œ๋ฅผ ๋ฐ›์„์ง€ ์—ฌ๋ถ€(y/n) ๋ฌป๋Š” ๋ฌธ๊ตฌ - - [ ] ๋”œ๋Ÿฌ ์นด๋“œ ์ถ”๊ฐ€์ ์œผ๋กœ ๋ฐ›์•˜์„ ๋•Œ ๋ฌธ๊ตฌ - - [ ] ์นด๋“œ ์ ์ˆ˜ ๊ณ„์‚ฐ ๊ฒฐ๊ณผ ์ถœ๋ ฅ - - [ ] ์ตœ์ข… ์ŠนํŒจ ๊ฒฐ๊ณผ ์ถœ๋ ฅ +- [x] ์ถœ๋ ฅ + - [x] ํ”Œ๋ ˆ์ด์–ด ์ด๋ฆ„ ์ž…๋ ฅํ•˜๊ธฐ ๋ฌธ๊ตฌ + - [x] ๊ฒŒ์ž„ ์‹œ์ž‘ ์‹œ ์นด๋“œ 2์žฅ ๋ฐฐ๋ถ„์— ๋Œ€ํ•œ ๋ฌธ๊ตฌ + - [x] ์ฐธ์—ฌ์ž ์นด๋“œ ๋ฆฌ์ŠคํŠธ ๋‚ด์˜ ์นด๋“œ ์ถœ๋ ฅ (jason์นด๋“œ: 7ํด๋กœ๋ฒ„, K์ŠคํŽ˜์ด๋“œ) + - [x] ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์นด๋“œ๋ฅผ ๋ฐ›์„์ง€ ์—ฌ๋ถ€(y/n) ๋ฌป๋Š” ๋ฌธ๊ตฌ + - [x] ๋”œ๋Ÿฌ ์นด๋“œ ์ถ”๊ฐ€์ ์œผ๋กœ ๋ฐ›์•˜์„ ๋•Œ ๋ฌธ๊ตฌ + - [x] ์นด๋“œ ์ ์ˆ˜ ๊ณ„์‚ฐ ๊ฒฐ๊ณผ ์ถœ๋ ฅ + - [x] ์ตœ์ข… ์ŠนํŒจ ๊ฒฐ๊ณผ ์ถœ๋ ฅ
diff --git a/src/main/java/view/OutputView.java b/src/main/java/view/OutputView.java index 0f733430..37c4befe 100644 --- a/src/main/java/view/OutputView.java +++ b/src/main/java/view/OutputView.java @@ -1,4 +1,4 @@ -package view.outputview; +package view; import carddeck.Card; import participant.Dealer; From 81233a800c921c944dfa48ad6c317c875e5e6498 Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Fri, 2 Feb 2024 18:01:14 +0900 Subject: [PATCH 24/48] =?UTF-8?q?=EC=9D=B4=EB=A6=84,=20=EC=9D=B4=EB=A6=84?= =?UTF-8?q?=20=EA=B2=80=EC=A6=9D=20=EA=B8=B0=EB=8A=A5=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +- src/main/java/participant/CardList.java | 11 +---- src/main/java/participant/Dealer.java | 6 ++- src/main/java/participant/Name.java | 15 +++++++ src/main/java/participant/NameChecker.java | 51 ++++++++++++++++++++++ src/main/java/participant/Participant.java | 21 ++++++--- src/main/java/participant/Player.java | 4 +- 7 files changed, 91 insertions(+), 21 deletions(-) create mode 100644 src/main/java/participant/Name.java create mode 100644 src/main/java/participant/NameChecker.java diff --git a/README.md b/README.md index 5f0faca4..3dfd1de9 100644 --- a/README.md +++ b/README.md @@ -30,9 +30,9 @@ - [x] ๋”œ๋Ÿฌ(์ฐธ๊ฐ€์ž ์ƒ์†) -- [ ] ์ด๋ฆ„: ์ฐธ๊ฐ€์ž์˜ ํ•„๋“œ +- [x] ์ด๋ฆ„: ์ฐธ๊ฐ€์ž์˜ ํ•„๋“œ -- [ ] ์ด๋ฆ„ ๊ฒ€์ฆ +- [x] ์ด๋ฆ„ ๊ฒ€์ฆ - [x] ์นด๋“œ ๋ฆฌ์ŠคํŠธ: ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๋ฐฐ๋ถ„ ๋ฐ›์€ ์นด๋“œ๋“ค ๋‹ด๋Š” ๋ฆฌ์ŠคํŠธ diff --git a/src/main/java/participant/CardList.java b/src/main/java/participant/CardList.java index 7c5fd3a6..4fb1c606 100644 --- a/src/main/java/participant/CardList.java +++ b/src/main/java/participant/CardList.java @@ -1,6 +1,6 @@ -package domain.participant; +package participant; -import domain.carddeck.Card; +import carddeck.Card; import java.util.ArrayList; import java.util.List; @@ -21,11 +21,4 @@ public List getCardList() { return this.cardList; } - public void setScore(int score) { - this.score = score; - } - - public int getScore() { - return this.score; - } } diff --git a/src/main/java/participant/Dealer.java b/src/main/java/participant/Dealer.java index 4e9c5452..2b5fe9b7 100644 --- a/src/main/java/participant/Dealer.java +++ b/src/main/java/participant/Dealer.java @@ -1,8 +1,10 @@ -package domain.participant; +package participant; public class Dealer extends Participant{ public Dealer() { - super("๋”œ๋Ÿฌ"); + super(new Name("๋”œ๋Ÿฌ")); } + + } \ No newline at end of file diff --git a/src/main/java/participant/Name.java b/src/main/java/participant/Name.java new file mode 100644 index 00000000..a7849f2a --- /dev/null +++ b/src/main/java/participant/Name.java @@ -0,0 +1,15 @@ +package participant; + +public class Name { + + private String name; + + public Name(String name) { + this.name = name.trim(); + } + + public String getName() { + return this.name; + } + +} diff --git a/src/main/java/participant/NameChecker.java b/src/main/java/participant/NameChecker.java new file mode 100644 index 00000000..67ed6a72 --- /dev/null +++ b/src/main/java/participant/NameChecker.java @@ -0,0 +1,51 @@ +package participant; + +import java.util.ArrayList; +import java.util.List; + +public class NameChecker { + + private List nameList; + private List newNameList; + + public NameChecker(List nameList) { + this.nameList = nameList; + this.newNameList = new ArrayList(); + } + + public void check() { + IsNameEmpty(); + IsNameEqualsDealer(); + hasDuplicateNames(); + } + + private void hasDuplicateNames() { + for (String name : nameList) { + if (this.newNameList.contains(name)) { + throw new IllegalArgumentException("์ด๋ฆ„ ์ค‘๋ณต"); + } + newNameList.add(name); + } + } + + private void IsNameEqualsDealer() { + for (String name : nameList) { + if (name.equals("๋”œ๋Ÿฌ")) { + throw new IllegalArgumentException("๋”œ๋Ÿฌ ์ด๋ฆ„ ์‚ฌ์šฉ ๋ถˆ๊ฐ€"); + } + } + } + + private void IsNameEmpty() { + for (String name : nameList) { + if (name.isEmpty() || name.isBlank()) { + throw new IllegalArgumentException("์ด๋ฆ„ ๋นˆ์นธ ๋ถˆ๊ฐ€"); + } + } + } + + public List getNewNameList() { + return this.newNameList; + } + +} diff --git a/src/main/java/participant/Participant.java b/src/main/java/participant/Participant.java index 1afb4aab..25fb6abd 100644 --- a/src/main/java/participant/Participant.java +++ b/src/main/java/participant/Participant.java @@ -1,20 +1,29 @@ -package domain.participant; +package participant; + +import carddeck.Card; + +import java.util.List; public class Participant { - private String name; + + private Name name; private CardList cardList; - public Participant(String name) { + public Participant(Name name) { this.name = name; this.cardList = new CardList(); } + public void receiveCard(Card card) { + this.cardList.addCard(card); + } + public String getName() { - return this.name; + return this.name.getName(); } - public CardList getCardList() { - return this.cardList; + public List getCardList() { + return this.cardList.getCardList(); } } diff --git a/src/main/java/participant/Player.java b/src/main/java/participant/Player.java index f1c0eafe..77b5a59b 100644 --- a/src/main/java/participant/Player.java +++ b/src/main/java/participant/Player.java @@ -1,7 +1,7 @@ -package domain.participant; +package participant; public class Player extends Participant{ - public Player(String name) { + public Player(Name name) { super(name); } } From 4a90047655f3cac8a689f5dad0dfb6d131fee65f Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Fri, 2 Feb 2024 18:02:24 +0900 Subject: [PATCH 25/48] =?UTF-8?q?=EB=B8=94=EB=9E=99=EC=9E=AD=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/domain/BlackJack.java | 50 +++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/main/java/domain/BlackJack.java diff --git a/src/main/java/domain/BlackJack.java b/src/main/java/domain/BlackJack.java new file mode 100644 index 00000000..0276924a --- /dev/null +++ b/src/main/java/domain/BlackJack.java @@ -0,0 +1,50 @@ +package domain; + +import carddeck.Card; +import carddeck.CardDeck; +import participant.Dealer; +import participant.Participant; + +import java.util.List; + +public class BlackJack { + + private final int INITIAL_CARD_DISTRIBUTION_COUNT = 2; + public final int DEALER_THRESHOLD = 16; + + private List participants; + private CardDeck cardDeck; + + public BlackJack(List participants) { + this.participants = participants; + this.cardDeck = new CardDeck(); + initialCardDistribution(); + } + + private void initialCardDistribution() { + for (Participant participant : participants) { + for (int i = 0; i < INITIAL_CARD_DISTRIBUTION_COUNT; i++) { + distributeCard(participant); + } + } + } + + public void distributeCard(Participant participant) { + try { + Card card = this.cardDeck.drawCard(); + participant.receiveCard(card); + } catch (IllegalArgumentException e) { + System.out.println("[ERROR] " + e.getMessage()); + } + } + + public boolean isDealerAboveThreshold(Dealer dealer) { + int score = ScoreCalculator.calculateScore(dealer); + if (score <= DEALER_THRESHOLD) { + distributeCard(dealer); + return true; + } + return false; + } + +} From 419da1cbb475ab5484155a3ee92e222e3dc57985 Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Fri, 2 Feb 2024 18:04:08 +0900 Subject: [PATCH 26/48] =?UTF-8?q?=EC=B9=B4=EB=93=9C=20=EC=A0=90=EC=88=98?= =?UTF-8?q?=20=EA=B3=84=EC=82=B0=20=EA=B8=B0=EB=8A=A5=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/domain/ScoreCalculator.java | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/main/java/domain/ScoreCalculator.java b/src/main/java/domain/ScoreCalculator.java index ee5b19af..b041d9a8 100644 --- a/src/main/java/domain/ScoreCalculator.java +++ b/src/main/java/domain/ScoreCalculator.java @@ -1,6 +1,35 @@ package domain; +import carddeck.Card; +import carddeck.CardRank; +import participant.Participant; + +import java.util.List; + public class ScoreCalculator { + public static int calculateScore(Participant participant) { + int sum = 0; + int numOfAce = 0; + List cardList = participant.getCardList(); + for (Card card : cardList) { + CardRank cardRank = card.getCardRank(); + if (cardRank.getRank().equals(CardRank.ACE.getRank())) { + numOfAce += 1; + } + sum += cardRank.getValue(); + } + sum = calculateAceValue(numOfAce, sum); + return sum; + } + + private static int calculateAceValue(int numOfAce, int sum) { + for (int i = 0; i < numOfAce; i++) { + if (sum + 10 <= 21) { + sum += 10; + } + } + return sum; + } } \ No newline at end of file From a13c714488a742fef92361a8a6c93457a193473d Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Fri, 2 Feb 2024 18:04:48 +0900 Subject: [PATCH 27/48] =?UTF-8?q?=EB=94=9C=EB=9F=AC=20=EC=8A=B9=EB=A6=AC?= =?UTF-8?q?=20=EC=B2=B4=ED=81=AC=20=EA=B8=B0=EB=8A=A5=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/domain/DealerWinChecker.java | 62 ++++++++++++++++++---- 1 file changed, 53 insertions(+), 9 deletions(-) diff --git a/src/main/java/domain/DealerWinChecker.java b/src/main/java/domain/DealerWinChecker.java index 5b39204f..49bd8951 100644 --- a/src/main/java/domain/DealerWinChecker.java +++ b/src/main/java/domain/DealerWinChecker.java @@ -1,25 +1,69 @@ package domain; +import constants.Constant; +import constants.Result; import participant.Dealer; -import participant.Participant; import participant.Player; -import java.util.concurrent.Delayed; +public class DealerWinChecker { -public class WinnerChecker { + private int dealerScore; + private int winNum; + private int loseNum; + private int pushNum; - private Dealer dealer; - private int score; + public DealerWinChecker(Dealer dealer) { + this.dealerScore = ScoreCalculator.calculateScore(dealer); + this.winNum = 0; + this.loseNum = 0; + } - public (Dealer dealer) { - this.dealer = dealer; - this.score = ScoreCalculator.calculateScore(dealer); + public Result checkDealerWin(Player player) { + int playerScore = ScoreCalculator.calculateScore(player); + boolean dealerBust = checkBust(this.dealerScore); + boolean playerBust = checkBust(playerScore); + if (dealerBust && playerBust) { + this.loseNum += 1; + return Result.BUST; + } + if (!dealerBust) { + if (playerBust || (this.dealerScore > playerScore)) { + this.winNum += 1; + return Result.PLAYER_LOSE; + } + } + if(!playerBust) { + if (dealerBust || (playerScore > this.dealerScore)) { + this.loseNum += 1; + return Result.PLAYER_WIN; + } + } + if (!(dealerBust && playerBust)) { + if (playerScore == this.dealerScore) { + pushNum += 1; + return Result.PUSH; + } + } + return null; } - public void check(Player player) { + private boolean checkBust(int score) { + if (score > Constant.TARGET_SCORE) { + return true; + } + return false; + } + public int getWinNum() { + return this.winNum; } + public int getLoseNum() { + return this.loseNum; + } + public int getPushNum() { + return this.pushNum; + } } From 85e3dc79f9d802a540dca7b3b38aac3a94c7831d Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Fri, 2 Feb 2024 18:07:54 +0900 Subject: [PATCH 28/48] =?UTF-8?q?=EC=83=81=EC=88=98=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 3dfd1de9..c2e8b3ae 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,12 @@ - [x] ์นด๋“œ๋ฑ: 52๊ฐ€์ง€ ์นด๋“œ ๋‹ด๊ณ  ์žˆ๋Š” ํ•˜๋‚˜์˜ ์นด๋“œ๋ฑ - [x] ์นด๋“œ๋ฑ์—์„œ ์นด๋“œ ์ถ”์ถœํ•˜์—ฌ ๋ฐ˜ํ™˜ +### constants + +- [x] ์ƒ์ˆ˜ + +- [x] ์ŠนํŒจ ๊ฒฐ๊ณผ ์ƒ์ˆ˜ + ### ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง From c6582799112f3d88d98ebd9c6cc2ccd99a0c3320 Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Fri, 2 Feb 2024 18:08:32 +0900 Subject: [PATCH 29/48] =?UTF-8?q?=EC=83=81=EC=88=98=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/constants/Constant.java | 4 +++- src/main/java/constants/Result.java | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/main/java/constants/Result.java diff --git a/src/main/java/constants/Constant.java b/src/main/java/constants/Constant.java index 69f242f3..cccd8fec 100644 --- a/src/main/java/constants/Constant.java +++ b/src/main/java/constants/Constant.java @@ -1,7 +1,9 @@ -package domain.constants; +package constants; public class Constant { public static final int TARGET_SCORE = 21; + public static final String YES = "y"; + public static final String NO = "n"; } diff --git a/src/main/java/constants/Result.java b/src/main/java/constants/Result.java new file mode 100644 index 00000000..1b5c2150 --- /dev/null +++ b/src/main/java/constants/Result.java @@ -0,0 +1,18 @@ +package constants; + +public enum Result { + PLAYER_WIN("์Šน"), + PLAYER_LOSE("ํŒจ"), + BUST("ํŒจ"), + PUSH("๋ฌด์Šน๋ถ€"); + + private final String value; + + Result(String value) { + this.value = value; + } + + public String getValue() { + return this.value; + } +} From 382161d6dd2d7e03bbcc632ee27d12a4d3fe23f5 Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Fri, 2 Feb 2024 18:09:21 +0900 Subject: [PATCH 30/48] =?UTF-8?q?=EC=B9=B4=EB=93=9C=EB=8D=B1=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/carddeck/Card.java | 4 ++-- src/main/java/carddeck/CardDeck.java | 24 ++++++++++++++---------- src/main/java/carddeck/CardRank.java | 4 ++-- src/main/java/carddeck/CardSuit.java | 2 +- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/main/java/carddeck/Card.java b/src/main/java/carddeck/Card.java index 528e4b39..f468f9e3 100644 --- a/src/main/java/carddeck/Card.java +++ b/src/main/java/carddeck/Card.java @@ -1,4 +1,4 @@ -package domain.carddeck; +package carddeck; public class Card { @@ -12,7 +12,7 @@ public Card(CardSuit cardSuit, CardRank cardRank) { @Override public String toString() { - return this.cardRank.getValue() + this.cardSuit.getValue(); + return this.cardRank.getRank() + this.cardSuit.getValue(); } public CardSuit getCardSuit() { diff --git a/src/main/java/carddeck/CardDeck.java b/src/main/java/carddeck/CardDeck.java index 7e90e2ca..06ab436b 100644 --- a/src/main/java/carddeck/CardDeck.java +++ b/src/main/java/carddeck/CardDeck.java @@ -1,19 +1,19 @@ -package domain.carddeck; +package carddeck; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.Random; public class CardDeck { - List cardDeck; + private List cardDeck; public CardDeck() { - generateCardDeck(); + initializeCardDeck(); + shuffleCardDeck(); } - private void generateCardDeck() { + private void initializeCardDeck() { CardSuit[] suits = CardSuit.values(); CardRank[] ranks = CardRank.values(); @@ -25,14 +25,18 @@ private void generateCardDeck() { this.cardDeck.add(card); } } - Collections.shuffle(this.cardDeck); } - public Card getCard() { + private void shuffleCardDeck() { + Collections.shuffle(this.cardDeck); + } - Card card = this.cardDeck.get(0); - this.cardDeck.remove(0); + public Card drawCard() { + if (this.cardDeck.isEmpty()) { + throw new IllegalArgumentException("์นด๋“œ๋ฑ์ด ๋น„์–ด ์žˆ์Šต๋‹ˆ๋‹ค."); + } - return card; + return this.cardDeck.remove(0); } + } diff --git a/src/main/java/carddeck/CardRank.java b/src/main/java/carddeck/CardRank.java index e3d0fb03..a0e9fac7 100644 --- a/src/main/java/carddeck/CardRank.java +++ b/src/main/java/carddeck/CardRank.java @@ -1,8 +1,8 @@ -package domain.carddeck; +package carddeck; public enum CardRank { - ACE_ONE("A", 1), ACE_ELEVEN("A", 11), TWO("2", 2), THREE("3", 3), FOUR("4", 4), FIVE("5", 5), + ACE("A", 1), 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); diff --git a/src/main/java/carddeck/CardSuit.java b/src/main/java/carddeck/CardSuit.java index 0fe9007f..a5b43dbe 100644 --- a/src/main/java/carddeck/CardSuit.java +++ b/src/main/java/carddeck/CardSuit.java @@ -1,4 +1,4 @@ -package domain.carddeck; +package carddeck; public enum CardSuit { HEARTS("ํ•˜ํŠธ"), DIAMONDS("๋‹ค์ด์•„๋ชฌ๋“œ"), CLUBS("ํด๋กœ๋ฒ„"), SPADES("์ŠคํŽ˜์ด๋“œ"); From 0b25c4498cc26b34069f6c427328798bc1e9ed2a Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Fri, 2 Feb 2024 18:11:05 +0900 Subject: [PATCH 31/48] =?UTF-8?q?=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 12 +-- src/main/java/controller/GameManager.java | 114 +++++++++++++++++++++- 2 files changed, 119 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c2e8b3ae..5299d27f 100644 --- a/README.md +++ b/README.md @@ -66,9 +66,9 @@ ## controller -- [ ] ๊ฒŒ์ž„ ๋งค๋‹ˆ์ € - - [ ] ๊ฒŒ์ž„ ์‹œ์ž‘ - - [ ] ์ฐธ๊ฐ€์ž ์ƒ์„ฑ - - [ ] ๋ธ”๋ž™์žญ ๊ฒŒ์ž„ ์‹œ์ž‘ - - [ ] ์ ์ˆ˜ ๊ณ„์‚ฐ ๊ฒฐ๊ณผ ์ถœ๋ ฅ - - [ ] ์ตœ์ข… ์ŠนํŒจ ๊ฒฐ๊ณผ ์ถœ๋ ฅ \ No newline at end of file +- [x] ๊ฒŒ์ž„ ๋งค๋‹ˆ์ € + - [x] ๊ฒŒ์ž„ ์‹œ์ž‘ + - [x] ์ฐธ๊ฐ€์ž ์ƒ์„ฑ + - [x] ๋ธ”๋ž™์žญ ๊ฒŒ์ž„ ์‹œ์ž‘ + - [x] ์ ์ˆ˜ ๊ณ„์‚ฐ ๊ฒฐ๊ณผ ์ถœ๋ ฅ + - [x] ์ตœ์ข… ์ŠนํŒจ ๊ฒฐ๊ณผ ์ถœ๋ ฅ \ No newline at end of file diff --git a/src/main/java/controller/GameManager.java b/src/main/java/controller/GameManager.java index d09a430b..e2858da2 100644 --- a/src/main/java/controller/GameManager.java +++ b/src/main/java/controller/GameManager.java @@ -1,4 +1,116 @@ package controller; -public class gameManager { +import constants.Constant; +import constants.Result; +import domain.BlackJack; +import domain.DealerWinChecker; +import domain.ScoreCalculator; +import participant.*; +import view.InputView; +import view.OutputView; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class GameManager { + + private InputView inputView; + private OutputView outputView; + private BlackJack blackJack; + + public GameManager() { + this.inputView = new InputView(); + this.outputView = new OutputView(); + } + + public void gameStart() { + List participants = new ArrayList(); + + Dealer dealer = new Dealer(); + participants.add(dealer); + + List playerNameList = getPlayerNameList(); + for (String name : playerNameList) { + Player player = new Player(new Name(name)); + participants.add(player); + } + + this.blackJack = new BlackJack(participants); + outputView.printInitialCardDistributionMessage(playerNameList); + + for (Participant participant : participants) { + outputView.printParticipantCardList(participant); + } + + outputView.printEmptyLine(); + + for (Participant participant : participants) { + if (participant instanceof Player) { + askForAdditionCard(participant); + } + } + + outputView.printEmptyLine(); + + if (blackJack.isDealerAboveThreshold(dealer)) { + outputView.printDealerGetOneMoreCard(); + } + + for (Participant participant : participants) { + int score = ScoreCalculator.calculateScore(participant); + outputView.printScore(participant, score); + } + + outputView.printEmptyLine(); + + DealerWinChecker dealerWinChecker = new DealerWinChecker(dealer); + HashMap playerResult = new HashMap<>(); + for (Participant participant : participants) { + if (participant instanceof Player) { + Result result = dealerWinChecker.checkDealerWin((Player) participant); + playerResult.put(participant.getName(), result.getValue()); + } + } + + List dealerResult = new ArrayList(); + dealerResult.add(dealerWinChecker.getWinNum()); + dealerResult.add(dealerWinChecker.getLoseNum()); + dealerResult.add(dealerWinChecker.getPushNum()); + + outputView.printFinalResult(dealerResult, playerResult); + + } + + private List getPlayerNameList() { + outputView.printInputPlayerNameMessage(); + List names = inputView.inputPlayerName(); + NameChecker nameChecker = new NameChecker(names); + try { + nameChecker.check(); + } catch (IllegalArgumentException e) { + System.out.println("[ERROR] " + e.getMessage()); + return getPlayerNameList(); + } + return names; + } + + private void askForAdditionCard(Participant participant) { + String name = participant.getName(); + try { + outputView.printAskForAdditionalCard(name); + String answer = inputView.askForAdditionalCard(); + if (answer.equals(Constant.YES)) { + this.blackJack.distributeCard(participant); + outputView.printParticipantCardList(participant); + askForAdditionCard(participant); + } + if (answer.equals(Constant.NO)) { + outputView.printParticipantCardList(participant); + } + } catch (IllegalArgumentException e) { + System.out.println("[ERROR] " + e.getMessage()); + askForAdditionCard(participant); + } + } } From 152ff202cec6b8cf6d4ce4d9f128d805a2c14311 Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Fri, 2 Feb 2024 18:14:57 +0900 Subject: [PATCH 32/48] =?UTF-8?q?Application=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/Application.java | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/src/main/java/Application.java b/src/main/java/Application.java index 97efc8be..b0b0391f 100644 --- a/src/main/java/Application.java +++ b/src/main/java/Application.java @@ -1,30 +1,9 @@ -import domain.CalculateScore; -import domain.CardDistributor; -import domain.carddeck.Card; -import domain.carddeck.CardDeck; -import domain.participant.Participant; -import domain.participant.PlayerList; -import view.outputview.OutputView; +import controller.GameManager; -public class application { +public class Application { public static void main(String[] args) { - OutputView outputView = new OutputView(); - - Participant participant = new Participant("kim"); - CardDeck cardDeck = new CardDeck(); - - CardDistributor cardDistributor = new CardDistributor(); - - cardDistributor.distributeOneCard(cardDeck, participant); - cardDistributor.distributeOneCard(cardDeck, participant); - cardDistributor.distributeOneCard(cardDeck, participant); - - for (Card card : participant.getCardList().getCardList()) { - System.out.println(card.toString()); - } - - CalculateScore calculateScore = new CalculateScore(); - System.out.println(calculateScore.calculator(participant)); + GameManager gameManager = new GameManager(); + gameManager.gameStart(); } } From 24261b25a97d5151422f34bfcd18873cc43f61e0 Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Tue, 6 Feb 2024 15:57:59 +0900 Subject: [PATCH 33/48] =?UTF-8?q?style:=20=ED=8C=8C=EC=9D=BC=20=EB=81=9D?= =?UTF-8?q?=20=EA=B0=9C=ED=96=89=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/participant/Dealer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/participant/Dealer.java b/src/main/java/participant/Dealer.java index 2b5fe9b7..7b8e6410 100644 --- a/src/main/java/participant/Dealer.java +++ b/src/main/java/participant/Dealer.java @@ -7,4 +7,4 @@ public Dealer() { } -} \ No newline at end of file +} From 08ef19fc2f96cb07fdb56776f30caf667cc778ee Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Tue, 6 Feb 2024 16:08:16 +0900 Subject: [PATCH 34/48] =?UTF-8?q?refactor:=20TARGET=5FSCORE=20=EA=B4=80?= =?UTF-8?q?=EB=A6=AC=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/constants/Constant.java | 1 - src/main/java/domain/DealerWinChecker.java | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/constants/Constant.java b/src/main/java/constants/Constant.java index cccd8fec..09d18ba7 100644 --- a/src/main/java/constants/Constant.java +++ b/src/main/java/constants/Constant.java @@ -2,7 +2,6 @@ public class Constant { - public static final int TARGET_SCORE = 21; public static final String YES = "y"; public static final String NO = "n"; diff --git a/src/main/java/domain/DealerWinChecker.java b/src/main/java/domain/DealerWinChecker.java index 49bd8951..63305ca2 100644 --- a/src/main/java/domain/DealerWinChecker.java +++ b/src/main/java/domain/DealerWinChecker.java @@ -7,6 +7,7 @@ public class DealerWinChecker { + private final int TARGET_SCORE = 21; private int dealerScore; private int winNum; private int loseNum; @@ -48,7 +49,7 @@ public Result checkDealerWin(Player player) { } private boolean checkBust(int score) { - if (score > Constant.TARGET_SCORE) { + if (score > TARGET_SCORE) { return true; } return false; From 1e6a1529487a22e4bca4823c5d4a8b90c8c0a527 Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Tue, 6 Feb 2024 16:36:31 +0900 Subject: [PATCH 35/48] =?UTF-8?q?docs:=20=EC=9D=B4=EB=A6=84=20=EA=B2=80?= =?UTF-8?q?=EC=A6=9D(=EA=B0=9D=EC=B2=B4)=20=EA=B8=B0=EB=8A=A5=EC=9D=84=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20=EA=B0=9D=EC=B2=B4=EC=99=80=20=ED=94=8C?= =?UTF-8?q?=EB=A0=88=EC=9D=B4=EC=96=B4=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EA=B0=9D=EC=B2=B4=EC=97=90=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5299d27f..203bdc7e 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ - [x] ์ด๋ฆ„: ์ฐธ๊ฐ€์ž์˜ ํ•„๋“œ -- [x] ์ด๋ฆ„ ๊ฒ€์ฆ +- [ ] ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ - [x] ์นด๋“œ ๋ฆฌ์ŠคํŠธ: ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๋ฐฐ๋ถ„ ๋ฐ›์€ ์นด๋“œ๋“ค ๋‹ด๋Š” ๋ฆฌ์ŠคํŠธ From 28a34f0944b825634cd767aaec226945513a0f7d Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Tue, 6 Feb 2024 16:38:52 +0900 Subject: [PATCH 36/48] =?UTF-8?q?feat:=20Name=EC=97=90=EB=94=9C=EB=9F=AC?= =?UTF-8?q?=20=EC=9D=B4=EB=A6=84=20=EC=82=AC=EC=9A=A9=20=EB=B6=88=EA=B0=80?= =?UTF-8?q?=20=EA=B8=B0=EB=8A=A5=EA=B3=BC=20=EC=9D=B4=EB=A6=84=20=EB=B9=88?= =?UTF-8?q?=EC=B9=B8=20=EB=B6=88=EA=B0=80=20=EA=B8=B0=EB=8A=A5=20=EC=9D=B4?= =?UTF-8?q?=EC=A0=84=20=ED=9B=84=20=EC=9D=B4=EB=A6=84=20=EA=B2=80=EC=A6=9D?= =?UTF-8?q?=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/participant/Name.java | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/main/java/participant/Name.java b/src/main/java/participant/Name.java index a7849f2a..bd5b247b 100644 --- a/src/main/java/participant/Name.java +++ b/src/main/java/participant/Name.java @@ -5,7 +5,30 @@ public class Name { private String name; public Name(String name) { - this.name = name.trim(); + String trimmedName = name.trim(); + validateName(trimmedName); + } + + private void validateName(String name) { + try { + IsNameEqualsDealer(name); + IsNameEmpty(name); + this.name = name; + } catch (IllegalArgumentException e) { + System.out.println(e.getMessage()); + } + } + + private void IsNameEqualsDealer(String name) { + if (name.equals("๋”œ๋Ÿฌ")) { + throw new IllegalArgumentException("๋”œ๋Ÿฌ ์ด๋ฆ„ ์‚ฌ์šฉ ๋ถˆ๊ฐ€"); + } + } + + private void IsNameEmpty(String name) { + if (name.isEmpty() || name.isBlank()) { + throw new IllegalArgumentException("์ด๋ฆ„ ๋นˆ์นธ ๋ถˆ๊ฐ€"); + } } public String getName() { From aa4d654d200d9c658eae66ef47895f1c754e2401 Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Tue, 6 Feb 2024 16:52:37 +0900 Subject: [PATCH 37/48] =?UTF-8?q?refactor:=20Name=20=EA=B0=9D=EC=B2=B4?= =?UTF-8?q?=EC=97=90=20=EA=B2=80=EC=A6=9D=20=EA=B8=B0=EB=8A=A5=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=88=98=EC=A0=95.=20=EC=98=88=EC=99=B8=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20=EA=B8=B0=EB=8A=A5=EC=9D=80=20Name=20?= =?UTF-8?q?=EA=B0=9D=EC=B2=B4=EC=97=90,=20try=20catch=EB=8A=94=20=EA=B2=8C?= =?UTF-8?q?=EC=9E=84=20=EB=A7=A4=EB=8B=88=EC=A0=80=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EA=B5=AC=EC=A1=B0=EB=A1=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/participant/Name.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/main/java/participant/Name.java b/src/main/java/participant/Name.java index bd5b247b..be1ccc40 100644 --- a/src/main/java/participant/Name.java +++ b/src/main/java/participant/Name.java @@ -6,17 +6,9 @@ public class Name { public Name(String name) { String trimmedName = name.trim(); - validateName(trimmedName); - } - - private void validateName(String name) { - try { - IsNameEqualsDealer(name); - IsNameEmpty(name); - this.name = name; - } catch (IllegalArgumentException e) { - System.out.println(e.getMessage()); - } + IsNameEqualsDealer(name); + IsNameEmpty(name); + this.name = name; } private void IsNameEqualsDealer(String name) { From f288e60b2ac41a983fe820d220ea702c8eaf3405 Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Tue, 6 Feb 2024 17:07:17 +0900 Subject: [PATCH 38/48] =?UTF-8?q?feat:=20=ED=94=8C=EB=A0=88=EC=9D=B4?= =?UTF-8?q?=EC=96=B4=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=99=84=EC=84=B1.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/participant/PlayerList.java | 39 +++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/main/java/participant/PlayerList.java diff --git a/src/main/java/participant/PlayerList.java b/src/main/java/participant/PlayerList.java new file mode 100644 index 00000000..d73bec5d --- /dev/null +++ b/src/main/java/participant/PlayerList.java @@ -0,0 +1,39 @@ +package participant; + +import java.util.ArrayList; +import java.util.List; + +public class PlayerList { + + private List playerList; + + public PlayerList(List playerNameList) { + List nameList = hasDuplicateNames(playerNameList); + this.playerList = generatePlayerList(nameList); + } + + private List hasDuplicateNames(List playerNameList) { + List processedNameList = new ArrayList(); + for (String name : playerNameList) { + String trimmedName = name.trim(); + if (processedNameList.contains(trimmedName)) { + throw new IllegalArgumentException("์ด๋ฆ„ ์ค‘๋ณต"); + } + processedNameList.add(trimmedName); + } + return processedNameList; + } + + private List generatePlayerList(List processedNameList) { + List playerList= new ArrayList(); + for (String name : processedNameList) { + playerList.add(new Player(new Name(name))); + } + return playerList; + } + + public List getPlayerList() { + return this.playerList; + } + +} From 07bee19ba95958facce5f1be1a92a7cb53f9e83d Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Tue, 6 Feb 2024 18:04:10 +0900 Subject: [PATCH 39/48] =?UTF-8?q?refactor:=20=EB=94=9C=EB=9F=AC=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20=EC=82=AC=EC=9A=A9=20=EB=B6=88=EA=B0=80=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20PlayerList=EB=A1=9C=20=EC=9D=B4=EC=A0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/participant/Name.java | 7 ------- src/main/java/participant/PlayerList.java | 9 ++++++++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/participant/Name.java b/src/main/java/participant/Name.java index be1ccc40..2f63c631 100644 --- a/src/main/java/participant/Name.java +++ b/src/main/java/participant/Name.java @@ -6,17 +6,10 @@ public class Name { public Name(String name) { String trimmedName = name.trim(); - IsNameEqualsDealer(name); IsNameEmpty(name); this.name = name; } - private void IsNameEqualsDealer(String name) { - if (name.equals("๋”œ๋Ÿฌ")) { - throw new IllegalArgumentException("๋”œ๋Ÿฌ ์ด๋ฆ„ ์‚ฌ์šฉ ๋ถˆ๊ฐ€"); - } - } - private void IsNameEmpty(String name) { if (name.isEmpty() || name.isBlank()) { throw new IllegalArgumentException("์ด๋ฆ„ ๋นˆ์นธ ๋ถˆ๊ฐ€"); diff --git a/src/main/java/participant/PlayerList.java b/src/main/java/participant/PlayerList.java index d73bec5d..ad1b342e 100644 --- a/src/main/java/participant/PlayerList.java +++ b/src/main/java/participant/PlayerList.java @@ -12,6 +12,12 @@ public PlayerList(List playerNameList) { this.playerList = generatePlayerList(nameList); } + private void IsNameEqualsDealer(String name) { + if (name.equals("๋”œ๋Ÿฌ")) { + throw new IllegalArgumentException("๋”œ๋Ÿฌ ์ด๋ฆ„ ์‚ฌ์šฉ ๋ถˆ๊ฐ€"); + } + } + private List hasDuplicateNames(List playerNameList) { List processedNameList = new ArrayList(); for (String name : playerNameList) { @@ -25,8 +31,9 @@ private List hasDuplicateNames(List playerNameList) { } private List generatePlayerList(List processedNameList) { - List playerList= new ArrayList(); + List playerList = new ArrayList(); for (String name : processedNameList) { + IsNameEqualsDealer(name); playerList.add(new Player(new Name(name))); } return playerList; From 255d7474aaf8bd232f4accfbdbe3b9e02ac77305 Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Tue, 6 Feb 2024 18:06:40 +0900 Subject: [PATCH 40/48] =?UTF-8?q?feat:=20=EC=9E=85=EB=A0=A5=EA=B0=92=20?= =?UTF-8?q?=EB=B9=88=EC=B9=B8=20=EB=B6=88=EA=B0=80=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80.=20=EC=9D=B4=EB=A6=84=20=EB=B9=88=EC=B9=B8?= =?UTF-8?q?=20=EB=B6=88=EA=B0=80=20=EA=B2=BD=EC=9A=B0=EC=99=80=20=EC=A1=B0?= =?UTF-8?q?=EA=B8=88=20=EB=8B=A4=EB=A6=84.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/participant/NameChecker.java | 51 ---------------------- src/main/java/view/InputView.java | 3 ++ 2 files changed, 3 insertions(+), 51 deletions(-) delete mode 100644 src/main/java/participant/NameChecker.java diff --git a/src/main/java/participant/NameChecker.java b/src/main/java/participant/NameChecker.java deleted file mode 100644 index 67ed6a72..00000000 --- a/src/main/java/participant/NameChecker.java +++ /dev/null @@ -1,51 +0,0 @@ -package participant; - -import java.util.ArrayList; -import java.util.List; - -public class NameChecker { - - private List nameList; - private List newNameList; - - public NameChecker(List nameList) { - this.nameList = nameList; - this.newNameList = new ArrayList(); - } - - public void check() { - IsNameEmpty(); - IsNameEqualsDealer(); - hasDuplicateNames(); - } - - private void hasDuplicateNames() { - for (String name : nameList) { - if (this.newNameList.contains(name)) { - throw new IllegalArgumentException("์ด๋ฆ„ ์ค‘๋ณต"); - } - newNameList.add(name); - } - } - - private void IsNameEqualsDealer() { - for (String name : nameList) { - if (name.equals("๋”œ๋Ÿฌ")) { - throw new IllegalArgumentException("๋”œ๋Ÿฌ ์ด๋ฆ„ ์‚ฌ์šฉ ๋ถˆ๊ฐ€"); - } - } - } - - private void IsNameEmpty() { - for (String name : nameList) { - if (name.isEmpty() || name.isBlank()) { - throw new IllegalArgumentException("์ด๋ฆ„ ๋นˆ์นธ ๋ถˆ๊ฐ€"); - } - } - } - - public List getNewNameList() { - return this.newNameList; - } - -} diff --git a/src/main/java/view/InputView.java b/src/main/java/view/InputView.java index 6c23874a..2290d63e 100644 --- a/src/main/java/view/InputView.java +++ b/src/main/java/view/InputView.java @@ -17,6 +17,9 @@ public InputView() { public List inputPlayerName() { String playerNameStr = this.sc.nextLine(); + if (playerNameStr.isBlank()) { + throw new IllegalArgumentException("๊ฐ’์„ ์ž…๋ ฅํ•˜์‹œ์˜ค."); + } List list = Arrays.asList(playerNameStr.split(",")); List playerNameList = new ArrayList(); for (String name : list) { From 678bb49f5c9bccf608cedbb9b4b910723acf2240 Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Tue, 6 Feb 2024 18:08:42 +0900 Subject: [PATCH 41/48] =?UTF-8?q?docs:=20=ED=94=8C=EB=A0=88=EC=9D=B4?= =?UTF-8?q?=EC=96=B4=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 203bdc7e..ffd383ea 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ - [x] ์ด๋ฆ„: ์ฐธ๊ฐ€์ž์˜ ํ•„๋“œ -- [ ] ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ +- [x] ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ - [x] ์นด๋“œ ๋ฆฌ์ŠคํŠธ: ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๋ฐฐ๋ถ„ ๋ฐ›์€ ์นด๋“œ๋“ค ๋‹ด๋Š” ๋ฆฌ์ŠคํŠธ From c4066ba0c0073eb8ad5747e5685824bbaf212c62 Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Tue, 6 Feb 2024 18:12:38 +0900 Subject: [PATCH 42/48] =?UTF-8?q?refactor:=20=EA=B2=8C=EC=9E=84=20?= =?UTF-8?q?=EB=A7=A4=EB=8B=88=EC=A0=80=20=EB=82=B4=EC=9D=98=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/controller/GameManager.java | 32 ++++++++++++----------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/main/java/controller/GameManager.java b/src/main/java/controller/GameManager.java index e2858da2..baca48b0 100644 --- a/src/main/java/controller/GameManager.java +++ b/src/main/java/controller/GameManager.java @@ -10,6 +10,7 @@ import view.OutputView; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.List; @@ -25,20 +26,22 @@ public GameManager() { } public void gameStart() { - List participants = new ArrayList(); + List playerList = getPlayerList(); + List participants = new ArrayList(); Dealer dealer = new Dealer(); participants.add(dealer); - - List playerNameList = getPlayerNameList(); - for (String name : playerNameList) { - Player player = new Player(new Name(name)); - participants.add(player); + for (Player player : playerList) { + participants.add((Participant) player); } - this.blackJack = new BlackJack(participants); + List playerNameList = new ArrayList(); + for (Player player : playerList) { + playerNameList.add(player.getName()); + } outputView.printInitialCardDistributionMessage(playerNameList); + this.blackJack = new BlackJack(participants); for (Participant participant : participants) { outputView.printParticipantCardList(participant); } @@ -82,17 +85,16 @@ public void gameStart() { } - private List getPlayerNameList() { - outputView.printInputPlayerNameMessage(); - List names = inputView.inputPlayerName(); - NameChecker nameChecker = new NameChecker(names); + private List getPlayerList() { try { - nameChecker.check(); + outputView.printInputPlayerNameMessage(); + List nameList = inputView.inputPlayerName(); + PlayerList playerList = new PlayerList(nameList); + return playerList.getPlayerList(); } catch (IllegalArgumentException e) { - System.out.println("[ERROR] " + e.getMessage()); - return getPlayerNameList(); + System.out.println(e.getMessage()); + return getPlayerList(); } - return names; } private void askForAdditionCard(Participant participant) { From 29d688f018117fcc419ba89513ef72454cefa902 Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Tue, 6 Feb 2024 18:27:03 +0900 Subject: [PATCH 43/48] =?UTF-8?q?docs:=20=EC=A0=90=EC=88=98=20=EA=B3=84?= =?UTF-8?q?=EC=82=B0=20=EA=B8=B0=EB=8A=A5=20=EC=B9=B4=EB=93=9C=20=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=EB=A1=9C=20=EC=9D=B4=EC=A0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ffd383ea..379570dc 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ ### participant - [x] ์ฐธ๊ฐ€์ž(ํด๋ž˜์Šค) - + - [ ] ์ ์ˆ˜ ๋ฐ˜ํ™˜ ๊ธฐ๋Šฅ - [x] ํ”Œ๋ ˆ์ด์–ด(์ฐธ๊ฐ€์ž ์ƒ์†) - [x] ๋”œ๋Ÿฌ(์ฐธ๊ฐ€์ž ์ƒ์†) @@ -35,6 +35,7 @@ - [x] ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ - [x] ์นด๋“œ ๋ฆฌ์ŠคํŠธ: ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๋ฐฐ๋ถ„ ๋ฐ›์€ ์นด๋“œ๋“ค ๋‹ด๋Š” ๋ฆฌ์ŠคํŠธ + - [ ] ์ ์ˆ˜ ๊ณ„์‚ฐ ๊ธฐ๋Šฅ ### carddeck From 1bf8d9f9c344b696ce146486716ab611035b9d14 Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Tue, 6 Feb 2024 18:28:52 +0900 Subject: [PATCH 44/48] =?UTF-8?q?feat:=20=EC=B9=B4=EB=93=9C=20=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=EC=97=90=20=EC=A0=90=EC=88=98=20=EA=B3=84?= =?UTF-8?q?=EC=82=B0=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/domain/ScoreCalculator.java | 35 ----------------------- src/main/java/participant/CardList.java | 24 ++++++++++++++++ 2 files changed, 24 insertions(+), 35 deletions(-) delete mode 100644 src/main/java/domain/ScoreCalculator.java diff --git a/src/main/java/domain/ScoreCalculator.java b/src/main/java/domain/ScoreCalculator.java deleted file mode 100644 index b041d9a8..00000000 --- a/src/main/java/domain/ScoreCalculator.java +++ /dev/null @@ -1,35 +0,0 @@ -package domain; - -import carddeck.Card; -import carddeck.CardRank; -import participant.Participant; - -import java.util.List; - -public class ScoreCalculator { - - public static int calculateScore(Participant participant) { - int sum = 0; - int numOfAce = 0; - List cardList = participant.getCardList(); - for (Card card : cardList) { - CardRank cardRank = card.getCardRank(); - if (cardRank.getRank().equals(CardRank.ACE.getRank())) { - numOfAce += 1; - } - sum += cardRank.getValue(); - } - sum = calculateAceValue(numOfAce, sum); - return sum; - } - - private static int calculateAceValue(int numOfAce, int sum) { - for (int i = 0; i < numOfAce; i++) { - if (sum + 10 <= 21) { - sum += 10; - } - } - return sum; - } - -} \ No newline at end of file diff --git a/src/main/java/participant/CardList.java b/src/main/java/participant/CardList.java index 4fb1c606..820cd22e 100644 --- a/src/main/java/participant/CardList.java +++ b/src/main/java/participant/CardList.java @@ -1,6 +1,7 @@ package participant; import carddeck.Card; +import carddeck.CardRank; import java.util.ArrayList; import java.util.List; @@ -17,6 +18,29 @@ public void addCard(Card card) { this.cardList.add(card); } + public int calculateScore() { + int sum = 0; + int numOfAce = 0; + for (Card card : cardList) { + CardRank cardRank = card.getCardRank(); + if (cardRank.getRank().equals(CardRank.ACE.getRank())) { + numOfAce += 1; + } + sum += cardRank.getValue(); + } + sum = calculateAceValue(numOfAce, sum); + return sum; + } + + private int calculateAceValue(int numOfAce, int sum) { + for (int i = 0; i < numOfAce; i++) { + if (sum + 10 <= 21) { + sum += 10; + } + } + return sum; + } + public List getCardList() { return this.cardList; } From d5bbcc52dd018116f81b68cc3ed7e245c05f29d2 Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Tue, 6 Feb 2024 18:30:26 +0900 Subject: [PATCH 45/48] =?UTF-8?q?feat:=20=EC=B0=B8=EA=B0=80=EC=9E=90=20?= =?UTF-8?q?=EA=B0=9D=EC=B2=B4=EC=97=90=20=EC=A0=90=EC=88=98=20=EB=B0=98?= =?UTF-8?q?=ED=99=98=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80.=20?= =?UTF-8?q?=EC=B0=B8=EA=B0=80=EC=9E=90=EC=9D=98=20=EC=B9=B4=EB=93=9C=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=EC=97=90=20=EB=8C=80=ED=95=B4?= =?UTF-8?q?=EC=84=9C=20=EC=A0=90=EC=88=98=20=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/participant/Participant.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/participant/Participant.java b/src/main/java/participant/Participant.java index 25fb6abd..3af601bc 100644 --- a/src/main/java/participant/Participant.java +++ b/src/main/java/participant/Participant.java @@ -22,6 +22,10 @@ public String getName() { return this.name.getName(); } + public int getScore() { + return this.cardList.calculateScore(); + } + public List getCardList() { return this.cardList.getCardList(); } From 9b19017f6b50882f6194fc5b874390d944bce6b5 Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Tue, 6 Feb 2024 18:31:32 +0900 Subject: [PATCH 46/48] =?UTF-8?q?refactor:=20=EC=A0=90=EC=88=98=20?= =?UTF-8?q?=EA=B3=84=EC=82=B0=20=EA=B8=B0=EB=8A=A5=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EB=8D=98=20=EA=B0=9D=EC=B2=B4=EB=93=A4=20=EB=AA=A8?= =?UTF-8?q?=EB=91=90=20=EC=88=98=EC=A0=95=20=EC=99=84=EB=A3=8C.=20?= =?UTF-8?q?=EC=A0=90=EC=88=98=20=EA=B3=84=EC=82=B0=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- src/main/java/controller/GameManager.java | 4 +--- src/main/java/domain/BlackJack.java | 2 +- src/main/java/domain/DealerWinChecker.java | 4 ++-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 379570dc..cc375006 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ ### participant - [x] ์ฐธ๊ฐ€์ž(ํด๋ž˜์Šค) - - [ ] ์ ์ˆ˜ ๋ฐ˜ํ™˜ ๊ธฐ๋Šฅ + - [x] ์ ์ˆ˜ ๋ฐ˜ํ™˜ ๊ธฐ๋Šฅ - [x] ํ”Œ๋ ˆ์ด์–ด(์ฐธ๊ฐ€์ž ์ƒ์†) - [x] ๋”œ๋Ÿฌ(์ฐธ๊ฐ€์ž ์ƒ์†) @@ -35,7 +35,7 @@ - [x] ํ”Œ๋ ˆ์ด์–ด ๋ฆฌ์ŠคํŠธ - [x] ์นด๋“œ ๋ฆฌ์ŠคํŠธ: ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๋ฐฐ๋ถ„ ๋ฐ›์€ ์นด๋“œ๋“ค ๋‹ด๋Š” ๋ฆฌ์ŠคํŠธ - - [ ] ์ ์ˆ˜ ๊ณ„์‚ฐ ๊ธฐ๋Šฅ + - [x] ์ ์ˆ˜ ๊ณ„์‚ฐ ๊ธฐ๋Šฅ ### carddeck diff --git a/src/main/java/controller/GameManager.java b/src/main/java/controller/GameManager.java index baca48b0..a2e377ad 100644 --- a/src/main/java/controller/GameManager.java +++ b/src/main/java/controller/GameManager.java @@ -4,13 +4,11 @@ import constants.Result; import domain.BlackJack; import domain.DealerWinChecker; -import domain.ScoreCalculator; import participant.*; import view.InputView; import view.OutputView; import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; import java.util.List; @@ -61,7 +59,7 @@ public void gameStart() { } for (Participant participant : participants) { - int score = ScoreCalculator.calculateScore(participant); + int score = participant.getScore(); outputView.printScore(participant, score); } diff --git a/src/main/java/domain/BlackJack.java b/src/main/java/domain/BlackJack.java index 0276924a..e1db17f6 100644 --- a/src/main/java/domain/BlackJack.java +++ b/src/main/java/domain/BlackJack.java @@ -39,7 +39,7 @@ public void distributeCard(Participant participant) { } public boolean isDealerAboveThreshold(Dealer dealer) { - int score = ScoreCalculator.calculateScore(dealer); + int score = dealer.getScore(); if (score <= DEALER_THRESHOLD) { distributeCard(dealer); return true; diff --git a/src/main/java/domain/DealerWinChecker.java b/src/main/java/domain/DealerWinChecker.java index 63305ca2..5a40f122 100644 --- a/src/main/java/domain/DealerWinChecker.java +++ b/src/main/java/domain/DealerWinChecker.java @@ -14,13 +14,13 @@ public class DealerWinChecker { private int pushNum; public DealerWinChecker(Dealer dealer) { - this.dealerScore = ScoreCalculator.calculateScore(dealer); + this.dealerScore = dealer.getScore(); this.winNum = 0; this.loseNum = 0; } public Result checkDealerWin(Player player) { - int playerScore = ScoreCalculator.calculateScore(player); + int playerScore = player.getScore(); boolean dealerBust = checkBust(this.dealerScore); boolean playerBust = checkBust(playerScore); if (dealerBust && playerBust) { From b74cf82b9f043248c4bb2ad55b66213faa2372e5 Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Tue, 6 Feb 2024 18:38:06 +0900 Subject: [PATCH 47/48] =?UTF-8?q?refactor:=20=EB=94=9C=EB=9F=AC=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20=EC=B9=B4=EB=93=9C=20=EB=B0=B0=EB=B6=84=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EA=B0=9C=EC=84=A0.=20=EB=94=9C=EB=9F=AC?= =?UTF-8?q?=20=EC=A0=90=EC=88=98=EA=B0=80=20=EC=A1=B0=EA=B1=B4=EC=9D=84=20?= =?UTF-8?q?=EB=A7=8C=EC=A1=B1=ED=95=98=EB=8A=94=EC=A7=80=20=ED=8C=90?= =?UTF-8?q?=EB=8B=A8=ED=95=98=EB=8A=94=20=EC=97=AD=ED=95=A0=EA=B3=BC=20?= =?UTF-8?q?=EC=B9=B4=EB=93=9C=EB=A5=BC=20=EB=B0=B0=EB=B6=84=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EC=97=AD=ED=95=A0=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/controller/GameManager.java | 1 + src/main/java/domain/BlackJack.java | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/controller/GameManager.java b/src/main/java/controller/GameManager.java index a2e377ad..558e9476 100644 --- a/src/main/java/controller/GameManager.java +++ b/src/main/java/controller/GameManager.java @@ -55,6 +55,7 @@ public void gameStart() { outputView.printEmptyLine(); if (blackJack.isDealerAboveThreshold(dealer)) { + blackJack.distributeCard(dealer); outputView.printDealerGetOneMoreCard(); } diff --git a/src/main/java/domain/BlackJack.java b/src/main/java/domain/BlackJack.java index e1db17f6..d9a7ad2e 100644 --- a/src/main/java/domain/BlackJack.java +++ b/src/main/java/domain/BlackJack.java @@ -41,7 +41,6 @@ public void distributeCard(Participant participant) { public boolean isDealerAboveThreshold(Dealer dealer) { int score = dealer.getScore(); if (score <= DEALER_THRESHOLD) { - distributeCard(dealer); return true; } return false; From f5b4361903db13863c8a29675766d398571af3ba Mon Sep 17 00:00:00 2001 From: "DESKTOP-F45SLBC\\bnj30" Date: Tue, 6 Feb 2024 19:02:45 +0900 Subject: [PATCH 48/48] =?UTF-8?q?refactor:=20instanceof=EB=A5=BC=20isDeale?= =?UTF-8?q?r=20=EB=A9=94=EC=86=8C=EB=93=9C=EB=A1=9C=20=EB=B0=94=EA=BF=88.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/controller/GameManager.java | 47 ++++++++++++++-------- src/main/java/participant/Dealer.java | 4 ++ src/main/java/participant/Participant.java | 4 ++ src/main/java/participant/Player.java | 5 +++ 4 files changed, 44 insertions(+), 16 deletions(-) diff --git a/src/main/java/controller/GameManager.java b/src/main/java/controller/GameManager.java index 558e9476..27607ff1 100644 --- a/src/main/java/controller/GameManager.java +++ b/src/main/java/controller/GameManager.java @@ -24,20 +24,8 @@ public GameManager() { } public void gameStart() { - List playerList = getPlayerList(); - - List participants = new ArrayList(); - Dealer dealer = new Dealer(); - participants.add(dealer); - for (Player player : playerList) { - participants.add((Participant) player); - } - - List playerNameList = new ArrayList(); - for (Player player : playerList) { - playerNameList.add(player.getName()); - } - outputView.printInitialCardDistributionMessage(playerNameList); + List participants = getParticipants(); + Dealer dealer = getDealer(participants); this.blackJack = new BlackJack(participants); for (Participant participant : participants) { @@ -47,7 +35,7 @@ public void gameStart() { outputView.printEmptyLine(); for (Participant participant : participants) { - if (participant instanceof Player) { + if (!participant.isDealer()) { askForAdditionCard(participant); } } @@ -69,7 +57,7 @@ public void gameStart() { DealerWinChecker dealerWinChecker = new DealerWinChecker(dealer); HashMap playerResult = new HashMap<>(); for (Participant participant : participants) { - if (participant instanceof Player) { + if (!participant.isDealer()) { Result result = dealerWinChecker.checkDealerWin((Player) participant); playerResult.put(participant.getName(), result.getValue()); } @@ -84,6 +72,33 @@ public void gameStart() { } + private List getParticipants() { + List playerList = getPlayerList(); + + List participants = new ArrayList(); + Dealer dealer = new Dealer(); + participants.add(dealer); + for (Player player : playerList) { + participants.add((Participant) player); + } + + List playerNameList = new ArrayList(); + for (Player player : playerList) { + playerNameList.add(player.getName()); + } + outputView.printInitialCardDistributionMessage(playerNameList); + return participants; + } + + private Dealer getDealer(List participants) { + for (Participant participant : participants) { + if (participant.isDealer()) { + return (Dealer) participant; + } + } + return null; + } + private List getPlayerList() { try { outputView.printInputPlayerNameMessage(); diff --git a/src/main/java/participant/Dealer.java b/src/main/java/participant/Dealer.java index 7b8e6410..2de5272c 100644 --- a/src/main/java/participant/Dealer.java +++ b/src/main/java/participant/Dealer.java @@ -6,5 +6,9 @@ public Dealer() { super(new Name("๋”œ๋Ÿฌ")); } + @Override + public boolean isDealer() { + return true; + } } diff --git a/src/main/java/participant/Participant.java b/src/main/java/participant/Participant.java index 3af601bc..63b14857 100644 --- a/src/main/java/participant/Participant.java +++ b/src/main/java/participant/Participant.java @@ -14,6 +14,10 @@ public Participant(Name name) { this.cardList = new CardList(); } + public boolean isDealer() { + return false; + } + public void receiveCard(Card card) { this.cardList.addCard(card); } diff --git a/src/main/java/participant/Player.java b/src/main/java/participant/Player.java index 77b5a59b..78cb1488 100644 --- a/src/main/java/participant/Player.java +++ b/src/main/java/participant/Player.java @@ -4,4 +4,9 @@ public class Player extends Participant{ public Player(Name name) { super(name); } + + @Override + public boolean isDealer() { + return false; + } }