From cb1ce7653d4e1c6e1b671836a3131a8be045a471 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 24 Jan 2024 23:19:05 +0900 Subject: [PATCH 01/23] =?UTF-8?q?docs:=20=EA=B8=B0=EB=8A=A5=20=EC=9A=94?= =?UTF-8?q?=EA=B5=AC=20=EC=82=AC=ED=95=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 76 -------------------------------------------------- docs/README.md | 26 +++++++++++++++++ 2 files changed, 26 insertions(+), 76 deletions(-) delete mode 100644 README.md create mode 100644 docs/README.md diff --git a/README.md b/README.md deleted file mode 100644 index 003db037..00000000 --- a/README.md +++ /dev/null @@ -1,76 +0,0 @@ -# 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)๋ฅผ ์ฐธ๊ณ ํ•ด ์ปค๋ฐ‹ ๋ฉ”์‹œ์ง€๋ฅผ ์ž‘์„ฑํ•œ๋‹ค. diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 00000000..beef0dd3 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,26 @@ +# ๊ธฐ๋Šฅ ๋ชฉ๋ก - ๋ธ”๋ž™์žญ ๊ฒŒ์ž„ + +## ์ž…๋ ฅ +- ๊ฒŒ์ž„์— ์ฐธ๊ฐ€ํ•  ํ”Œ๋ ˆ์ด์–ด์˜ ์ด๋ฆ„์„ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค (์‰ผํ‘œ ๊ธฐ์ค€์œผ๋กœ ๋ถ„๋ฆฌ) +- ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์นด๋“œ๋ฅผ ๋” ๋ฐ›์„์ง€ ๋ฐ›์ง€ ์•Š์„์ง€ y ํ˜น์€ n์œผ๋กœ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค. + +## ์ž…๋ ฅ์‹œ ์˜ˆ์™ธ์ฒ˜๋ฆฌ +- ํ”Œ๋ ˆ์ด์–ด์˜ ์ด๋ฆ„์„ ์ž…๋ ฅ๋ฐ›์„ ๋•Œ ํƒ€์ž…์ด ๋งž์ง€ ์•Š์œผ๋ฉด ์˜ˆ์™ธ์ฒ˜๋ฆฌ +- ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์นด๋“œ๋ฅผ ๋” ๋ฐ›์„์ง€ ์œ ๋ฌด๋ฅผ ์ž…๋ ฅ๋ฐ›์„ ๋•Œ y ํ˜น์€ n์ด ์•„๋‹ˆ๋ฉด ์˜ˆ์™ธ์ฒ˜๋ฆฌ + +## ๋ธ”๋ž™์žญ ๊ฒŒ์ž„ ๊ตฌํ˜„ +- ์นด๋“œ์˜ ์ˆซ์ž ๊ณ„์‚ฐ์€ ์นด๋“œ ์ˆซ์ž๋ฅผ ๊ธฐ๋ณธ์œผ๋กœ ace๋Š” 1 ๋˜๋Š” 11๋กœ ๊ณ„์‚ฐํ•œ๋‹ค. +- king, queen, jack์€ ๊ฐ๊ฐ 10์œผ๋กœ ๊ณ„์‚ฐํ•œ๋‹ค. +- ๊ฒŒ์ž„์„ ์‹œ์ž‘ํ•˜๋ฉด ํ”Œ๋ ˆ์ด์–ด๋Š” ๋‘์žฅ์˜ ์นด๋“œ๋ฅผ ์ง€๊ธ‰ ๋ฐ›์œผ๋ฉฐ, ๋‘ ์žฅ์˜ ์นด๋“œ ์ˆซ์ž๊ฐ€ 21์„ ์ดˆ๊ณผํ•˜์ง€ ์•Š์„ ๊ฒฝ์šฐ์—๋Š” ์นด๋“œ๋ฅผ ๋” ๋ฝ‘์„ ์ˆ˜ ์žˆ์Œ. +- ๋”œ๋Ÿฌ๋Š” ์ฒ˜์Œ์— ๋ฐ›์€ 2์žฅ์˜ ํ•ฉ๊ณ„๊ฐ€ 16์ดํ•˜๋ฉด ๋ฐ˜๋“œ์‹œ 1์žฅ์˜ ์นด๋“œ๋ฅผ ์ถ”๊ฐ€๋กœ ๋ฝ‘์Œ. +- ๊ฒŒ์ž„์˜ ์ŠนํŒจ๋Š” ๋”œ๋Ÿฌ๋ณด๋‹ค ๋†’์œผ๋ฉด์„œ ์นด๋“œ ์ˆซ์ž์˜ ์ดํ•ฉ์ด 21์„ ๋„˜์ง€ ์•Š์Œ์œผ๋กœ ๊ตฌ๋ถ„. + +## ์ถœ๋ ฅ +- ๊ฒŒ์ž„์— ์ฐธ์—ฌํ•  ์‚ฌ๋žŒ์˜ ์ž…๋ ฅํ•˜๋ผ๋Š” ๋ฌธ๊ตฌ ์ถœ๋ ฅ +- ํ”Œ๋ ˆ์ด ์‹œ์ž‘์‹œ 2์žฅ์„ ๋‚˜๋ˆ„์—ˆ๋‹ค๋Š” ๋ฌธ๊ตฌ ์ถœ๋ ฅ +- ํ”Œ๋ ˆ์ด ์‹œ์ž‘์‹œ ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด๋“ค์ด ๋ฐ›์€ ์นด๋“œ๋“ค์„ ์ถœ๋ ฅ +- ๊ฐ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์นด๋“œ๋ฅผ ๋” ๋ฐ›์„์ง€๋ฅผ ๋ฌป๋Š” ๋ฌธ๊ตฌ ์ถœ๋ ฅ +- ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด๋“ค์ด ์นด๋“œ๋ฅผ ๋ฐ›์„ ๋•Œ ๋งˆ๋‹ค ๊ฐ์ž์˜ ์นด๋“œ ์†Œ์œ  ํ˜„ํ™ฉ์„ ์ถœ๋ ฅ. +- ๋”œ๋Ÿฌ๊ฐ€ 16์ดํ•˜๋ผ ์นด๋“œ๋ฅผ ํ•œ์žฅ ๋” ๋ฐ›๋Š” ๊ฒฝ์šฐ ๊ทธ ๋ฌธ๊ตฌ๋ฅผ ์ถœ๋ ฅ. +- ๊ฒŒ์ž„์˜ ๊ฒฐ๊ณผ ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด๋“ค์˜ ์นด๋“œ ์†Œ์œ  ํ˜„ํ™ฉ๊ณผ ์ ์ˆ˜์˜ ํ•ฉ์„ ์ถœ๋ ฅ. +- ์ตœ์ข… ์ŠนํŒจ๋ฅผ ์ถœ๋ ฅ. \ No newline at end of file From 6005b684f1e08a14933032548d602650684af8c9 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 25 Jan 2024 00:58:06 +0900 Subject: [PATCH 02/23] =?UTF-8?q?docs:=20=EC=B6=94=EC=83=81=ED=99=94?= =?UTF-8?q?=EB=A1=9C=20=ED=8C=8C=EC=9D=BC=20=EB=A8=BC=EC=A0=80=20=EB=A7=8C?= =?UTF-8?q?=EB=93=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/controller/BlackJackController.java | 21 +++++++++++++++++++ src/main/java/domain/BlackJackGame.java | 4 ++++ src/main/java/domain/CardGenerator.java | 4 ++++ src/main/java/domain/Dealer.java | 4 ++++ src/main/java/domain/Player.java | 4 ++++ src/main/java/domain/ScoreCounter.java | 4 ++++ 6 files changed, 41 insertions(+) create mode 100644 src/main/java/controller/BlackJackController.java create mode 100644 src/main/java/domain/BlackJackGame.java create mode 100644 src/main/java/domain/CardGenerator.java create mode 100644 src/main/java/domain/Dealer.java create mode 100644 src/main/java/domain/Player.java create mode 100644 src/main/java/domain/ScoreCounter.java diff --git a/src/main/java/controller/BlackJackController.java b/src/main/java/controller/BlackJackController.java new file mode 100644 index 00000000..17c50314 --- /dev/null +++ b/src/main/java/controller/BlackJackController.java @@ -0,0 +1,21 @@ +package controller; + +import domain.BlackJackGame; +import view.input.InputView; +import view.output.ResultView; + +public class BlackJackController { + + private final InputView inputView; + private final ResultView resultView; + private BlackJackGame blackJackGame; + + public BlackJackController(InputView inputView, ResultView resultView){ + this.inputView = inputView; + this.resultView = resultView; + } + + public void start(){ + + } +} diff --git a/src/main/java/domain/BlackJackGame.java b/src/main/java/domain/BlackJackGame.java new file mode 100644 index 00000000..4b209d72 --- /dev/null +++ b/src/main/java/domain/BlackJackGame.java @@ -0,0 +1,4 @@ +package domain; + +public class BlackJackGame { +} diff --git a/src/main/java/domain/CardGenerator.java b/src/main/java/domain/CardGenerator.java new file mode 100644 index 00000000..6c527c82 --- /dev/null +++ b/src/main/java/domain/CardGenerator.java @@ -0,0 +1,4 @@ +package domain; + +public class CardGenerator { +} diff --git a/src/main/java/domain/Dealer.java b/src/main/java/domain/Dealer.java new file mode 100644 index 00000000..c0094ad1 --- /dev/null +++ b/src/main/java/domain/Dealer.java @@ -0,0 +1,4 @@ +package domain; + +public class Dealer { +} diff --git a/src/main/java/domain/Player.java b/src/main/java/domain/Player.java new file mode 100644 index 00000000..8894ec20 --- /dev/null +++ b/src/main/java/domain/Player.java @@ -0,0 +1,4 @@ +package domain; + +public class Player { +} diff --git a/src/main/java/domain/ScoreCounter.java b/src/main/java/domain/ScoreCounter.java new file mode 100644 index 00000000..9ccc5fac --- /dev/null +++ b/src/main/java/domain/ScoreCounter.java @@ -0,0 +1,4 @@ +package domain; + +public class ScoreCounter { +} From 64109661a52611893973be884a632e6bab8d1a44 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 25 Jan 2024 01:00:15 +0900 Subject: [PATCH 03/23] =?UTF-8?q?feat:=20Inputview=20=ED=81=B4=EB=9E=98?= =?UTF-8?q?=EC=8A=A4=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/view/input/InputView.java | 31 +++++++++++++++++++++++ src/main/java/view/output/ResultView.java | 4 +++ 2 files changed, 35 insertions(+) create mode 100644 src/main/java/view/input/InputView.java create mode 100644 src/main/java/view/output/ResultView.java diff --git a/src/main/java/view/input/InputView.java b/src/main/java/view/input/InputView.java new file mode 100644 index 00000000..a4425923 --- /dev/null +++ b/src/main/java/view/input/InputView.java @@ -0,0 +1,31 @@ +package view.input; + +import java.util.Scanner; +import java.util.List; + +public class InputView { + private final String PLAYER_NAMES_INPUT_MESSAGE = "๊ฒŒ์ž„์— ์ฐธ์—ฌํ•  ์‚ฌ๋žŒ์˜ ์ด๋ฆ„์„ ์ž…๋ ฅํ•˜์„ธ์š”.(์‰ผํ‘œ ๊ธฐ์ค€์œผ๋กœ ๋ถ„๋ฆฌ)"; + private final String PLAYER_GET_CARD_INPUT_MESSAGE = "%s๋Š” ํ•œ์žฅ์˜ ์นด๋“œ๋ฅผ ๋” ๋ฐ›๊ฒ ์Šต๋‹ˆ๊นŒ?(์˜ˆ๋Š” y, ์•„๋‹ˆ์˜ค๋Š” n)"; + + private final Scanner scanner; + public InputView() { + this.scanner = new Scanner(System.in); + } + + public List readPlayerName(){ + System.out.println(PLAYER_NAMES_INPUT_MESSAGE); + + final String delimiter = ","; + String playerNames = scanner.nextLine(); + + return List.of(playerNames.split(delimiter)); + } + + public String readGetCardMoreOrNot(String player){ + System.out.printf(PLAYER_GET_CARD_INPUT_MESSAGE, player); + + String yesOrNo = scanner.nextLine(); + + return yesOrNo; + } +} diff --git a/src/main/java/view/output/ResultView.java b/src/main/java/view/output/ResultView.java new file mode 100644 index 00000000..e61c99e1 --- /dev/null +++ b/src/main/java/view/output/ResultView.java @@ -0,0 +1,4 @@ +package view.output; + +public class ResultView { +} From a1d31036e0bac980da3ff391c12b7f84691d83cf Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 25 Jan 2024 01:01:56 +0900 Subject: [PATCH 04/23] =?UTF-8?q?=EB=88=84=EB=9D=BD=20=EB=B0=A9=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 2 +- src/main/java/Application.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 src/main/java/Application.java diff --git a/docs/README.md b/docs/README.md index beef0dd3..db900a63 100644 --- a/docs/README.md +++ b/docs/README.md @@ -19,7 +19,7 @@ - ๊ฒŒ์ž„์— ์ฐธ์—ฌํ•  ์‚ฌ๋žŒ์˜ ์ž…๋ ฅํ•˜๋ผ๋Š” ๋ฌธ๊ตฌ ์ถœ๋ ฅ - ํ”Œ๋ ˆ์ด ์‹œ์ž‘์‹œ 2์žฅ์„ ๋‚˜๋ˆ„์—ˆ๋‹ค๋Š” ๋ฌธ๊ตฌ ์ถœ๋ ฅ - ํ”Œ๋ ˆ์ด ์‹œ์ž‘์‹œ ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด๋“ค์ด ๋ฐ›์€ ์นด๋“œ๋“ค์„ ์ถœ๋ ฅ -- ๊ฐ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์นด๋“œ๋ฅผ ๋” ๋ฐ›์„์ง€๋ฅผ ๋ฌป๋Š” ๋ฌธ๊ตฌ ์ถœ๋ ฅ +- ๊ฐ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์นด๋“œ๋ฅผ ๋” ๋ฐ›์„์ง€๋ฅผ ์ž…๋ ฅํ•˜๋ผ๋Š” ๋ฌธ๊ตฌ ์ถœ๋ ฅ - ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด๋“ค์ด ์นด๋“œ๋ฅผ ๋ฐ›์„ ๋•Œ ๋งˆ๋‹ค ๊ฐ์ž์˜ ์นด๋“œ ์†Œ์œ  ํ˜„ํ™ฉ์„ ์ถœ๋ ฅ. - ๋”œ๋Ÿฌ๊ฐ€ 16์ดํ•˜๋ผ ์นด๋“œ๋ฅผ ํ•œ์žฅ ๋” ๋ฐ›๋Š” ๊ฒฝ์šฐ ๊ทธ ๋ฌธ๊ตฌ๋ฅผ ์ถœ๋ ฅ. - ๊ฒŒ์ž„์˜ ๊ฒฐ๊ณผ ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด๋“ค์˜ ์นด๋“œ ์†Œ์œ  ํ˜„ํ™ฉ๊ณผ ์ ์ˆ˜์˜ ํ•ฉ์„ ์ถœ๋ ฅ. diff --git a/src/main/java/Application.java b/src/main/java/Application.java new file mode 100644 index 00000000..092a8a40 --- /dev/null +++ b/src/main/java/Application.java @@ -0,0 +1,9 @@ +import controller.BlackJackController; +import view.input.InputView; +import view.output.ResultView; + +public class Application { + public static void main(String[] args) { + new BlackJackController(new InputView(), new ResultView()).start(); + } +} From dab31ea4ce09509a7364f5994592e46820b85b88 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 28 Jan 2024 03:09:43 +0900 Subject: [PATCH 05/23] =?UTF-8?q?docs:=20=EC=B6=94=EC=83=81=ED=99=94=20?= =?UTF-8?q?=ED=81=B4=EB=9E=98=EC=8A=A4=20=EB=A7=8C=EB=93=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/domain/Card.java | 4 ++++ src/main/java/domain/CardDeck.java | 4 ++++ src/main/java/domain/CardGenerator.java | 4 ---- src/main/java/domain/Player.java | 2 ++ 4 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 src/main/java/domain/Card.java create mode 100644 src/main/java/domain/CardDeck.java delete mode 100644 src/main/java/domain/CardGenerator.java diff --git a/src/main/java/domain/Card.java b/src/main/java/domain/Card.java new file mode 100644 index 00000000..5530951d --- /dev/null +++ b/src/main/java/domain/Card.java @@ -0,0 +1,4 @@ +package domain; + +public class Card { +} diff --git a/src/main/java/domain/CardDeck.java b/src/main/java/domain/CardDeck.java new file mode 100644 index 00000000..583c169b --- /dev/null +++ b/src/main/java/domain/CardDeck.java @@ -0,0 +1,4 @@ +package domain; + +public class CardDeck { +} diff --git a/src/main/java/domain/CardGenerator.java b/src/main/java/domain/CardGenerator.java deleted file mode 100644 index 6c527c82..00000000 --- a/src/main/java/domain/CardGenerator.java +++ /dev/null @@ -1,4 +0,0 @@ -package domain; - -public class CardGenerator { -} diff --git a/src/main/java/domain/Player.java b/src/main/java/domain/Player.java index 8894ec20..de475f06 100644 --- a/src/main/java/domain/Player.java +++ b/src/main/java/domain/Player.java @@ -1,4 +1,6 @@ package domain; public class Player { + private + private } From 3a7d2e56c072e0f405a46cf88d55aee771302623 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 28 Jan 2024 03:55:49 +0900 Subject: [PATCH 06/23] =?UTF-8?q?feat:=20Card.java=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/domain/Card.java | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/main/java/domain/Card.java b/src/main/java/domain/Card.java index 5530951d..707f043b 100644 --- a/src/main/java/domain/Card.java +++ b/src/main/java/domain/Card.java @@ -1,4 +1,41 @@ package domain; public class Card { + private String pattern; + private String mark; + private int number; + + Card(String pattern, String mark, int number) { + this.pattern = pattern; + this.mark = mark; + this.number = number; + } + + Card(String pattern, int index) { + this.pattern = pattern; + this.mark = indexToMark(index); + this.number = indexToNumber(index); + } + + private String indexToMark(int index) { + if (number == 1) { + return "A"; + } + if (number == 11) { + return "J"; + } + if (number == 12) { + return "Q"; + } + if (number == 13) { + return "K"; + } + return String.valueOf(index); + } + + private int indexToNumber(int index) { + if (index > 10) return 10; + return number; + } + } From e2d205daeafcdd48dac02ffa4b98e6cfc4b3dcb6 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 28 Jan 2024 03:56:30 +0900 Subject: [PATCH 07/23] =?UTF-8?q?CardGenerator.java=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/domain/CardGenerator.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/main/java/domain/CardGenerator.java diff --git a/src/main/java/domain/CardGenerator.java b/src/main/java/domain/CardGenerator.java new file mode 100644 index 00000000..5ff283ba --- /dev/null +++ b/src/main/java/domain/CardGenerator.java @@ -0,0 +1,23 @@ +package domain; + +import java.util.List; + +public class CardGenerator { + private List cards; + private static final String[] PATTERNS = {"์ŠคํŽ˜์ด๋“œ", "ํ•˜ํŠธ", "ํด๋กœ๋ฒ„", "๋‹ค์ด์•„๋ชฌ๋“œ"}; + private static final int MAX_INDEX = 13; + + CardGenerator() { + } + + public List generateCards() { + for (String pattern : PATTERNS) { + for (int i = 1; i <= MAX_INDEX; i++) { + Card card = new Card(pattern, i); + cards.add(card); + } + } + return cards; + } + +} From 6b61c4f11946547cd2abf6b388e6211ff5db7717 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 28 Jan 2024 04:46:35 +0900 Subject: [PATCH 08/23] feat: CardDeck.java --- src/main/java/domain/CardDeck.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/java/domain/CardDeck.java b/src/main/java/domain/CardDeck.java index 583c169b..f451ce45 100644 --- a/src/main/java/domain/CardDeck.java +++ b/src/main/java/domain/CardDeck.java @@ -1,4 +1,23 @@ package domain; +import java.util.List; + public class CardDeck { + private List deck = new CardGenerator().generateCards(); + + public CardDeck() { + } + + public Card draw() { + Card selectedCard = getRandomCard(); + deck.remove(selectedCard); + return selectedCard; + } + + public Card getRandomCard(){ + int selectedCardIndex = (int) (Math.random() * deck.size()); + return deck.get(selectedCardIndex); + } + + } From 9275a171390e1695e852c1dec775397886b45eb6 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 28 Jan 2024 05:06:41 +0900 Subject: [PATCH 09/23] =?UTF-8?q?feat:=20Player.java=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/domain/CardGenerator.java | 3 ++- src/main/java/domain/Player.java | 23 +++++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/main/java/domain/CardGenerator.java b/src/main/java/domain/CardGenerator.java index 5ff283ba..5e037ee5 100644 --- a/src/main/java/domain/CardGenerator.java +++ b/src/main/java/domain/CardGenerator.java @@ -1,9 +1,10 @@ package domain; +import java.util.ArrayList; import java.util.List; public class CardGenerator { - private List cards; + private List cards = new ArrayList<>(); private static final String[] PATTERNS = {"์ŠคํŽ˜์ด๋“œ", "ํ•˜ํŠธ", "ํด๋กœ๋ฒ„", "๋‹ค์ด์•„๋ชฌ๋“œ"}; private static final int MAX_INDEX = 13; diff --git a/src/main/java/domain/Player.java b/src/main/java/domain/Player.java index de475f06..36cc24cf 100644 --- a/src/main/java/domain/Player.java +++ b/src/main/java/domain/Player.java @@ -1,6 +1,25 @@ package domain; +import java.util.ArrayList; +import java.util.List; + public class Player { - private - private + private final String playerName; + private final List playerCardList = new ArrayList<>(); + + public Player(String playerName){ + this.playerName = playerName; + } + + public void receiveCard(Card receivedCard){ + playerCardList.add(receivedCard); + } + + public String getPlayerName(){ + return this.playerName; + } + + public List getPlayerCardList(){ + return this.playerCardList; + } } From d8ee67493f976aa66e90395c1f19b00491813dde Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 28 Jan 2024 06:48:20 +0900 Subject: [PATCH 10/23] =?UTF-8?q?refactor:=20Player.java=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/domain/Player.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/domain/Player.java b/src/main/java/domain/Player.java index 36cc24cf..cd564119 100644 --- a/src/main/java/domain/Player.java +++ b/src/main/java/domain/Player.java @@ -7,6 +7,7 @@ public class Player { private final String playerName; private final List playerCardList = new ArrayList<>(); + private int score = 0; public Player(String playerName){ this.playerName = playerName; } @@ -22,4 +23,14 @@ public String getPlayerName(){ public List getPlayerCardList(){ return this.playerCardList; } + + public int getScore() { + this.calculateScore(); + return score; + } + public void calculateScore(){ + for (Card card : playerCardList){ + score += card.getNumber(); + } + } } From 603bc1cfa3df44fc1b7fe4a56445595818ead433 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 28 Jan 2024 06:48:46 +0900 Subject: [PATCH 11/23] =?UTF-8?q?refactor:=20Dealer.java=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/domain/Dealer.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/domain/Dealer.java b/src/main/java/domain/Dealer.java index c0094ad1..a7fd6211 100644 --- a/src/main/java/domain/Dealer.java +++ b/src/main/java/domain/Dealer.java @@ -1,4 +1,11 @@ package domain; -public class Dealer { +public class Dealer extends Player { + Dealer(){ + super("Dealer"); + } + + public Card getStartCard(){ + return this.getPlayerCardList().get(0); + } } From c791a65d27a65fb72e817006c081922fb94b6823 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 28 Jan 2024 06:49:04 +0900 Subject: [PATCH 12/23] =?UTF-8?q?refactor:=20Card.java=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/domain/Card.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/domain/Card.java b/src/main/java/domain/Card.java index 707f043b..0ae0f1b0 100644 --- a/src/main/java/domain/Card.java +++ b/src/main/java/domain/Card.java @@ -38,4 +38,8 @@ private int indexToNumber(int index) { return number; } + public int getNumber(){ + return number; + } + } From e056d31b6517b71144c98505efedc557a994d83d Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 28 Jan 2024 06:49:41 +0900 Subject: [PATCH 13/23] =?UTF-8?q?refactor:=20ScaoreCounter=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/domain/ScoreCounter.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/domain/ScoreCounter.java b/src/main/java/domain/ScoreCounter.java index 9ccc5fac..cfbed363 100644 --- a/src/main/java/domain/ScoreCounter.java +++ b/src/main/java/domain/ScoreCounter.java @@ -1,4 +1,5 @@ package domain; public class ScoreCounter { + } From 323a922fe35313898fe99f3a79f4679abfce3686 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 28 Jan 2024 06:50:28 +0900 Subject: [PATCH 14/23] =?UTF-8?q?feat:=20BlackJackGame.java=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/domain/BlackJackGame.java | 43 +++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/main/java/domain/BlackJackGame.java b/src/main/java/domain/BlackJackGame.java index 4b209d72..5e7c7840 100644 --- a/src/main/java/domain/BlackJackGame.java +++ b/src/main/java/domain/BlackJackGame.java @@ -1,4 +1,47 @@ package domain; +import view.input.InputView; + +import java.util.List; +import java.util.stream.Collectors; + public class BlackJackGame { + private InputView input = new InputView(); + private Dealer dealer = new Dealer(); + private List players; + private CardDeck cardDeck = new CardDeck(); + + BlackJackGame(List splitPlayerNames) { + players = splitPlayerNames.stream() + .map(playerNames -> new Player(playerNames)) + .collect(Collectors.toList()); + } + + public void play() { + startPhase(); + + + } + + public void startPhase() { + dealer.receiveCard(cardDeck.draw()); + dealer.receiveCard(cardDeck.draw()); + if (dealer.getScore() <= 16) + dealer.receiveCard(cardDeck.draw()); + for (Player player : players) { + player.receiveCard(cardDeck.draw()); + player.receiveCard(cardDeck.draw()); + } + } + + public void playerPhase(Player player) { + String answer = ""; + while(answer != "n" || player.getScore() <= 21){ + answer = input.readGetCardMoreOrNot(player.getPlayerName()); + if(answer == "n"){ + break; + } + player.receiveCard(cardDeck.draw()); + } + } } From 61d4d4f16d2d1d3bbd7f68874473a5a0f3381973 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 28 Jan 2024 07:11:33 +0900 Subject: [PATCH 15/23] =?UTF-8?q?refactor:=20BlackJackGame=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=EC=A4=91.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/domain/BlackJackGame.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/domain/BlackJackGame.java b/src/main/java/domain/BlackJackGame.java index 5e7c7840..74813c33 100644 --- a/src/main/java/domain/BlackJackGame.java +++ b/src/main/java/domain/BlackJackGame.java @@ -19,7 +19,7 @@ public class BlackJackGame { public void play() { startPhase(); - + playPhase(); } @@ -33,8 +33,12 @@ public void startPhase() { player.receiveCard(cardDeck.draw()); } } - - public void playerPhase(Player player) { + public void playPhase(){ + for (Player player : players){ + eachPlayerPhase(player); + } + } + public void eachPlayerPhase(Player player) { String answer = ""; while(answer != "n" || player.getScore() <= 21){ answer = input.readGetCardMoreOrNot(player.getPlayerName()); From 7f72de0d5e1a2b20ed6f7e58c6e36de1a2e87c47 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 29 Jan 2024 00:56:22 +0900 Subject: [PATCH 16/23] =?UTF-8?q?refactor:=20Player.java=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/domain/Player.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/domain/Player.java b/src/main/java/domain/Player.java index cd564119..e04bcde5 100644 --- a/src/main/java/domain/Player.java +++ b/src/main/java/domain/Player.java @@ -6,8 +6,9 @@ public class Player { private final String playerName; private final List playerCardList = new ArrayList<>(); - private int score = 0; + private boolean winOrNot = false; + public Player(String playerName){ this.playerName = playerName; } @@ -33,4 +34,7 @@ public void calculateScore(){ score += card.getNumber(); } } + public void isWinner(){ + this.winOrNot = true; + } } From dab21cfb77273927a8788a4e5cf4b61bedc4be73 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 29 Jan 2024 00:56:53 +0900 Subject: [PATCH 17/23] =?UTF-8?q?refactor:=20BlackJackGame.java=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 --- src/main/java/domain/BlackJackGame.java | 51 +++++++++++++++---------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/src/main/java/domain/BlackJackGame.java b/src/main/java/domain/BlackJackGame.java index 74813c33..983441e1 100644 --- a/src/main/java/domain/BlackJackGame.java +++ b/src/main/java/domain/BlackJackGame.java @@ -1,51 +1,62 @@ package domain; -import view.input.InputView; - +import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; public class BlackJackGame { - private InputView input = new InputView(); private Dealer dealer = new Dealer(); private List players; private CardDeck cardDeck = new CardDeck(); - - BlackJackGame(List splitPlayerNames) { + private List winners = new ArrayList<>(); + public BlackJackGame(List splitPlayerNames) { players = splitPlayerNames.stream() .map(playerNames -> new Player(playerNames)) .collect(Collectors.toList()); } - public void play() { - startPhase(); - playPhase(); - - } - public void startPhase() { dealer.receiveCard(cardDeck.draw()); dealer.receiveCard(cardDeck.draw()); - if (dealer.getScore() <= 16) - dealer.receiveCard(cardDeck.draw()); for (Player player : players) { player.receiveCard(cardDeck.draw()); player.receiveCard(cardDeck.draw()); } } - public void playPhase(){ + public void playPhase(String getCardMoreOrNot){ for (Player player : players){ - eachPlayerPhase(player); + eachPlayerPhase(player, getCardMoreOrNot); } } - public void eachPlayerPhase(Player player) { - String answer = ""; - while(answer != "n" || player.getScore() <= 21){ - answer = input.readGetCardMoreOrNot(player.getPlayerName()); - if(answer == "n"){ + public void eachPlayerPhase(Player player, String getCardMoreOrNot) { + String answer = "y"; + if(player.getScore() > 17) return; + while(answer.equals("y") || player.getScore() <= 21){ + answer = getCardMoreOrNot; + if(answer.equals("n")){ break; } player.receiveCard(cardDeck.draw()); } } + + public void dealerPhase(){ + if (dealer.getScore() <= 16) + dealer.receiveCard(cardDeck.draw()); + } + + public List getWinner(){ + gattherWinner(players); + return winners; + } + public void gattherWinner(List players){ + for(Player player : players){ + if(player.getScore() >dealer.getScore()){ + player.isWinner(); + this.winners.add(player); + } + } + } + + } From 1c05a505e2451dfab5a9a1c2cde629e4c679c0d4 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 29 Jan 2024 00:58:35 +0900 Subject: [PATCH 18/23] =?UTF-8?q?feat:=20BlackJackController.java=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/controller/BlackJackController.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/controller/BlackJackController.java b/src/main/java/controller/BlackJackController.java index 17c50314..bd46101e 100644 --- a/src/main/java/controller/BlackJackController.java +++ b/src/main/java/controller/BlackJackController.java @@ -4,6 +4,8 @@ import view.input.InputView; import view.output.ResultView; +import java.util.List; + public class BlackJackController { private final InputView inputView; @@ -18,4 +20,17 @@ public BlackJackController(InputView inputView, ResultView resultView){ public void start(){ } + + public void makeBlackJackGame(List playerNames){ + this.blackJackGame = new BlackJackGame(playerNames); + } + public void startBlackJackGame(){ + blackJackGame.startPhase(); + blackJackGame.playPhase(inputView.readGetCardMoreOrNot()); + blackJackGame.dealerPhase(); + } + + public void showResultBlackJackGame(){ + + } } From 4d5ea763e4e9e26af80818da971005cc9d6eb5c6 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 31 Jan 2024 04:33:37 +0900 Subject: [PATCH 19/23] =?UTF-8?q?refactor:=20BlackJackGame.java=20?= =?UTF-8?q?=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/domain/BlackJackGame.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/domain/BlackJackGame.java b/src/main/java/domain/BlackJackGame.java index 983441e1..005ec9bf 100644 --- a/src/main/java/domain/BlackJackGame.java +++ b/src/main/java/domain/BlackJackGame.java @@ -9,6 +9,7 @@ public class BlackJackGame { private List players; private CardDeck cardDeck = new CardDeck(); private List winners = new ArrayList<>(); + public BlackJackGame(List splitPlayerNames) { players = splitPlayerNames.stream() .map(playerNames -> new Player(playerNames)) From 2a9723b42a717c4207aa9f16f666022f7a46b2e1 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 31 Jan 2024 04:46:17 +0900 Subject: [PATCH 20/23] =?UTF-8?q?refactor:=20BlackJackGame.java=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 --- src/main/java/domain/BlackJackGame.java | 12 ++++++++---- src/main/java/domain/CardGenerator.java | 24 ------------------------ 2 files changed, 8 insertions(+), 28 deletions(-) delete mode 100644 src/main/java/domain/CardGenerator.java diff --git a/src/main/java/domain/BlackJackGame.java b/src/main/java/domain/BlackJackGame.java index 005ec9bf..23113900 100644 --- a/src/main/java/domain/BlackJackGame.java +++ b/src/main/java/domain/BlackJackGame.java @@ -5,15 +5,19 @@ import java.util.stream.Collectors; public class BlackJackGame { - private Dealer dealer = new Dealer(); + private Dealer dealer; private List players; - private CardDeck cardDeck = new CardDeck(); - private List winners = new ArrayList<>(); - + private CardDeck cardDeck; + private List winners; + public BlackJackGame(List splitPlayerNames) { players = splitPlayerNames.stream() .map(playerNames -> new Player(playerNames)) .collect(Collectors.toList()); + dealer = new Dealer(); + cardDeck = new CardDeck(); + winners = new ArrayList<>(); + cardDeck.generateCards(); } public void startPhase() { diff --git a/src/main/java/domain/CardGenerator.java b/src/main/java/domain/CardGenerator.java deleted file mode 100644 index 5e037ee5..00000000 --- a/src/main/java/domain/CardGenerator.java +++ /dev/null @@ -1,24 +0,0 @@ -package domain; - -import java.util.ArrayList; -import java.util.List; - -public class CardGenerator { - private List cards = new ArrayList<>(); - private static final String[] PATTERNS = {"์ŠคํŽ˜์ด๋“œ", "ํ•˜ํŠธ", "ํด๋กœ๋ฒ„", "๋‹ค์ด์•„๋ชฌ๋“œ"}; - private static final int MAX_INDEX = 13; - - CardGenerator() { - } - - public List generateCards() { - for (String pattern : PATTERNS) { - for (int i = 1; i <= MAX_INDEX; i++) { - Card card = new Card(pattern, i); - cards.add(card); - } - } - return cards; - } - -} From 2cf308c1d6c7f80d5a22495274eca50f26c259f6 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 31 Jan 2024 04:47:25 +0900 Subject: [PATCH 21/23] =?UTF-8?q?refactor:=20CardDeck.java=EC=99=80CardGen?= =?UTF-8?q?erator=20=ED=86=B5=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/domain/CardDeck.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/domain/CardDeck.java b/src/main/java/domain/CardDeck.java index f451ce45..93e3af90 100644 --- a/src/main/java/domain/CardDeck.java +++ b/src/main/java/domain/CardDeck.java @@ -1,11 +1,15 @@ package domain; +import java.util.ArrayList; import java.util.List; public class CardDeck { - private List deck = new CardGenerator().generateCards(); + private List deck; + private static final String[] PATTERNS = {"์ŠคํŽ˜์ด๋“œ", "ํ•˜ํŠธ", "ํด๋กœ๋ฒ„", "๋‹ค์ด์•„๋ชฌ๋“œ"}; + private static final int MAX_INDEX = 13; public CardDeck() { + deck = new ArrayList<>(); } public Card draw() { @@ -18,6 +22,14 @@ public Card getRandomCard(){ int selectedCardIndex = (int) (Math.random() * deck.size()); return deck.get(selectedCardIndex); } + public void generateCards() { + for (String pattern : PATTERNS) { + for (int i = 1; i <= MAX_INDEX; i++) { + Card card = new Card(pattern, i); + deck.add(card); + } + } + } } From dc7e71f5b06215fd23d1bd42956badc414cd3bea Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 31 Jan 2024 04:51:29 +0900 Subject: [PATCH 22/23] =?UTF-8?q?refactor:=20Player.java=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=EC=9E=90=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/Player.java | 3 ++- src/main/java/domain/ScoreCounter.java | 5 ----- 2 files changed, 2 insertions(+), 6 deletions(-) delete mode 100644 src/main/java/domain/ScoreCounter.java diff --git a/src/main/java/domain/Player.java b/src/main/java/domain/Player.java index e04bcde5..86599960 100644 --- a/src/main/java/domain/Player.java +++ b/src/main/java/domain/Player.java @@ -5,12 +5,13 @@ public class Player { private final String playerName; - private final List playerCardList = new ArrayList<>(); + private final List playerCardList; private int score = 0; private boolean winOrNot = false; public Player(String playerName){ this.playerName = playerName; + this.playerCardList = new ArrayList<>(); } public void receiveCard(Card receivedCard){ diff --git a/src/main/java/domain/ScoreCounter.java b/src/main/java/domain/ScoreCounter.java deleted file mode 100644 index cfbed363..00000000 --- a/src/main/java/domain/ScoreCounter.java +++ /dev/null @@ -1,5 +0,0 @@ -package domain; - -public class ScoreCounter { - -} From cb90ca1ee4fba953e2bed42c53b957ebbe8ea67d Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 31 Jan 2024 04:53:13 +0900 Subject: [PATCH 23/23] =?UTF-8?q?refactor:=20Player.java=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=EC=9E=90=20=EC=88=98=EC=A0=952?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/domain/Player.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/domain/Player.java b/src/main/java/domain/Player.java index 86599960..47768502 100644 --- a/src/main/java/domain/Player.java +++ b/src/main/java/domain/Player.java @@ -6,12 +6,14 @@ public class Player { private final String playerName; private final List playerCardList; - private int score = 0; - private boolean winOrNot = false; + private int score; + private boolean winOrNot; public Player(String playerName){ this.playerName = playerName; this.playerCardList = new ArrayList<>(); + this.score = 0; + this. winOrNot = false; } public void receiveCard(Card receivedCard){