diff --git a/README.md b/README.md deleted file mode 100644 index 003db037a..000000000 --- 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 000000000..db900a636 --- /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 diff --git a/src/main/java/Application.java b/src/main/java/Application.java new file mode 100644 index 000000000..092a8a40c --- /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(); + } +} diff --git a/src/main/java/controller/BlackJackController.java b/src/main/java/controller/BlackJackController.java new file mode 100644 index 000000000..bd46101ea --- /dev/null +++ b/src/main/java/controller/BlackJackController.java @@ -0,0 +1,36 @@ +package controller; + +import domain.BlackJackGame; +import view.input.InputView; +import view.output.ResultView; + +import java.util.List; + +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(){ + + } + + public void makeBlackJackGame(List playerNames){ + this.blackJackGame = new BlackJackGame(playerNames); + } + public void startBlackJackGame(){ + blackJackGame.startPhase(); + blackJackGame.playPhase(inputView.readGetCardMoreOrNot()); + blackJackGame.dealerPhase(); + } + + public void showResultBlackJackGame(){ + + } +} diff --git a/src/main/java/domain/BlackJackGame.java b/src/main/java/domain/BlackJackGame.java new file mode 100644 index 000000000..231139002 --- /dev/null +++ b/src/main/java/domain/BlackJackGame.java @@ -0,0 +1,67 @@ +package domain; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +public class BlackJackGame { + private Dealer dealer; + private List players; + 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() { + dealer.receiveCard(cardDeck.draw()); + dealer.receiveCard(cardDeck.draw()); + for (Player player : players) { + player.receiveCard(cardDeck.draw()); + player.receiveCard(cardDeck.draw()); + } + } + public void playPhase(String getCardMoreOrNot){ + for (Player player : players){ + eachPlayerPhase(player, getCardMoreOrNot); + } + } + 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); + } + } + } + + +} diff --git a/src/main/java/domain/Card.java b/src/main/java/domain/Card.java new file mode 100644 index 000000000..0ae0f1b0d --- /dev/null +++ b/src/main/java/domain/Card.java @@ -0,0 +1,45 @@ +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; + } + + public int getNumber(){ + return number; + } + +} diff --git a/src/main/java/domain/CardDeck.java b/src/main/java/domain/CardDeck.java new file mode 100644 index 000000000..93e3af90a --- /dev/null +++ b/src/main/java/domain/CardDeck.java @@ -0,0 +1,35 @@ +package domain; + +import java.util.ArrayList; +import java.util.List; + +public class CardDeck { + private List deck; + private static final String[] PATTERNS = {"์ŠคํŽ˜์ด๋“œ", "ํ•˜ํŠธ", "ํด๋กœ๋ฒ„", "๋‹ค์ด์•„๋ชฌ๋“œ"}; + private static final int MAX_INDEX = 13; + + public CardDeck() { + deck = new ArrayList<>(); + } + + 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); + } + public void generateCards() { + for (String pattern : PATTERNS) { + for (int i = 1; i <= MAX_INDEX; i++) { + Card card = new Card(pattern, i); + deck.add(card); + } + } + } + + +} diff --git a/src/main/java/domain/Dealer.java b/src/main/java/domain/Dealer.java new file mode 100644 index 000000000..a7fd6211b --- /dev/null +++ b/src/main/java/domain/Dealer.java @@ -0,0 +1,11 @@ +package domain; + +public class Dealer extends Player { + Dealer(){ + super("Dealer"); + } + + public Card getStartCard(){ + return this.getPlayerCardList().get(0); + } +} diff --git a/src/main/java/domain/Player.java b/src/main/java/domain/Player.java new file mode 100644 index 000000000..477685029 --- /dev/null +++ b/src/main/java/domain/Player.java @@ -0,0 +1,43 @@ +package domain; + +import java.util.ArrayList; +import java.util.List; + +public class Player { + private final String playerName; + private final List playerCardList; + 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){ + playerCardList.add(receivedCard); + } + + public String getPlayerName(){ + return this.playerName; + } + + public List getPlayerCardList(){ + return this.playerCardList; + } + + public int getScore() { + this.calculateScore(); + return score; + } + public void calculateScore(){ + for (Card card : playerCardList){ + score += card.getNumber(); + } + } + public void isWinner(){ + this.winOrNot = true; + } +} diff --git a/src/main/java/view/input/InputView.java b/src/main/java/view/input/InputView.java new file mode 100644 index 000000000..a44259232 --- /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 000000000..e61c99e10 --- /dev/null +++ b/src/main/java/view/output/ResultView.java @@ -0,0 +1,4 @@ +package view.output; + +public class ResultView { +}