Skip to content

[๐Ÿš€ ์‚ฌ์ดํด2 - ๋ฏธ์…˜ (๋ธ”๋ž™์žญ ๊ฒŒ์ž„ ์‹คํ–‰)] ์•„ํ‹ฐ ๋ฏธ์…˜ ์ œ์ถœํ•ฉ๋‹ˆ๋‹ค.#1113

Open
ParkJiYeoung8297 wants to merge 93 commits intowoowacourse:parkjiyeoung8297from
ParkJiYeoung8297:step2

Conversation

@ParkJiYeoung8297
Copy link

@ParkJiYeoung8297 ParkJiYeoung8297 commented Mar 13, 2026

์‚ฌ์ดํด 2

๊ธฐ๋Šฅ

  • ๋ฐฐํŒ… ๊ธˆ์•ก ์ž…์ถœ๋ ฅ ๊ธฐ๋Šฅ ๊ตฌํ˜„
  • ์ „์ฒด ๋ฐฐํŒ… ๊ธˆ์•ก ๊ตฌํ•˜๋Š” ๊ธฐ๋Šฅ ์ถ”๊ฐ€
  • ์ตœ์ข… ์ˆ˜์ต ์ถœ๋ ฅํ•˜๋Š” ๊ธฐ๋Šฅ ๊ตฌํ˜„
  • ๋ฐฐํŒ… ๊ธˆ์•ก ์˜ˆ์™ธ ์‹œ ์žฌ์ž…๋ ฅ ๊ธฐ๋Šฅ ์ถ”๊ฐ€
  • ํ”Œ๋ ˆ์ด์–ด burst๋ฉด ์ƒ๊ธˆ ์žƒ๋Š” ๊ธฐ๋Šฅ ์ถ”๊ฐ€
  • ๋”œ๋Ÿฌ ์ˆ˜์ต ๊ณ„์‚ฐ ๊ธˆ์•ก ๊ธฐ๋Šฅ ๊ตฌํ˜„

์‚ฌ์ดํด1 ํ”ผ๋“œ๋ฐฑ ๋ฐ˜์˜

  • Player์˜ ํ•„๋“œ List๋ฅผ ์ผ๊ธ‰์ปฌ๋ ‰์…˜ Cards๋กœ ๋ณ€๊ฒฝ
  • ๊ธฐ์กด Cards๋Š” ์ „์ฒด ์นด๋“œ๋ฅผ ์˜๋ฏธํ•ด์„œ Player์—์„œ ์‚ฌ์šฉ ๋ชปํ–ˆ์Šต๋‹ˆ๋‹ค.
    ์ด๋ฒˆ ์ˆ˜์ • ๊ณผ์ •์—์„œ ์ „์ฒด ์นด๋“œ๋Š” Deck์ด๋ผ๋Š” ๋„๋ฉ”์ธ์„ ์ถ”๊ฐ€ํ•˜๊ณ , Cards๋Š” Player๊ฐ€ ๋“ค๊ณ ์žˆ๋Š” ์นด๋“œ ๋ญ‰์น˜๋กœ ์‚ฌ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค.
  • Dealer์™€ Player์˜ ์ƒ์† ๊ด€๊ณ„๋ฅผ ์ œ๊ฑฐ
  • Dealer์™€ Player์˜ ์ƒ์† ๊ด€๊ณ„๋กœ ์ธํ•ด Dealer๊ฐ€ ๋ชฐ๋ผ๋„ ๋˜๋Š” Player์˜ ํ–‰๋™์„ ์ƒ์†๋ฐ›๊ณ  ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.
    ์ด๋ฅผ ํ•ด๊ฒฐํ•˜๊ณ ์ž Player์™€ ๊ฒน์น˜๋Š” ํ–‰๋™์€ Player์—์„œ ์ฒ˜๋ฆฌํ•˜๊ณ , ๋”œ๋Ÿฌ์˜ ๊ทœ์น™์€ ๊ณง ๊ฒŒ์ž„์˜ ๊ทœ์น™์ด๊ธฐ์— Game์—์„œ ์ฒ˜๋ฆฌํ•˜๋„๋ก ๋ณ€๊ฒฝํ–ˆ์Šต๋‹ˆ๋‹ค.
  • ๋„๋ฉ”์ธ์—์„œ DTO ์ง์ ‘ ์ƒ์„ฑํ–ˆ๋˜ ๊ฒƒ์„ Service์—๊ฒŒ ์ฑ…์ž„ ์ด๋™
  • Controller์—์„œ ์ถœ๋ ฅํ•˜๋Š” ์ฑ…์ž„์„ OutputView๋กœ ์ด๋™
  • ํ•˜๋“œ ์ฝ”๋”ฉ ์ƒ์ˆ˜ํ™”
  • ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” import ์ •๋ฆฌ

To ๋ฆฌ๋ทฐ์–ด

1.Dealer - Player
๋”œ๋Ÿฌ์˜ ํ–‰๋™(ex. ์ž์‹ ์ด ๊ฐ€์ง„ ์นด๋“œ์˜ ํ•ฉ ๊ตฌํ•˜๊ธฐ)์€ Player์™€ ์ค‘๋ณต์ด๊ณ ,
๋”œ๋Ÿฌ์˜ ๊ทœ์น™(ex. 16์ดํ•˜์ด๋ฉด ์นด๋“œ๋ฅผ ์ถ”๊ฐ€๋กœ ๋ฐ›๋Š”๋‹ค.)์€ ๊ฒŒ์ž„์˜ ๊ทœ์น™์ด๊ธฐ์— Game์—์„œ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ์Šต๋‹ˆ๋‹ค.
๊ฐ์ฒด์—์„œ์˜ ์ฑ…์ž„์€ ํ˜„์‹ค์„ธ๊ณ„์™€ ์ฐจ์ด๊ฐ€ ์žˆ์–ด์„œ, ๊ผญ ๋”œ๋Ÿฌ๊ฐ€ ํ•˜๋Š” ํ–‰๋™์ด๋ผ๊ณ  Dealer์— ์žˆ์–ด์•ผํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ ์‘์ง‘๋„๋ฅผ ๊ณ ๋ คํ•ด ๋‹ค๋ฅธ ๊ณณ์— ์œ„์น˜ํ•  ์ˆ˜ ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ•˜๋Š”๋ฐ, ์ด๋Ÿฐ ๊ตฌ์กฐ๋กœ ๊ตฌํ˜„ํ•˜๋Š” ๊ฒƒ์— ๋Œ€ํ•ด ํ”ผ๋“œ๋ฐฑ ๋ฐ›๊ณ  ์‹ถ์Šต๋‹ˆ๋‹ค.

(์ด๋Ÿฐ ๊ตฌ์กฐ โ†’ ์ฝ”๋“œ ์ค‘๋ณต์„ ์ค„์ด๊ธฐ ์œ„ํ•ด Dealer ๊ฐ์ฒด๋ฅผ ์—†์• ๊ณ , ๊ด€๋ จ ํ–‰๋™๊ณผ ๊ทœ์น™์„ ์ ์ ˆํ•œ ํด๋ž˜์Šค์— ๋‘”๋‹ค)

  1. Domain
    ์ง€๊ธˆ ๋ณ€๊ฒฝํ•œ ๋„๋ฉ”์ธ ๊ตฌ์กฐ๊ฐ€ ์ž˜ ์งœ์—ฌ์ง„ ๊ฒƒ์ธ์ง€ ํ”ผ๋“œ๋ฐฑ ๋ฐ›๊ณ  ์‹ถ์Šต๋‹ˆ๋‹ค. ์–ด์ฐŒ๋ณด๋ฉด Game์ด aggregate root์™€ ๊ฐ™๋‹ค๊ณ  ๋ณด์ด๋Š”๋ฐ, ์ด๋Ÿฐ ๊ตฌ์กฐ๊ฐ€ ์ ์ ˆํ• ๊นŒ์š”?

  2. ํ…Œ์ŠคํŠธ ์ˆ˜์ •
    ๋„๋ฉ”์ธ์ด ๋Œ€๊ฑฐ ์ˆ˜์ •๋˜๋‹ˆ, ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋„ ๋‹ค์‹œ ์ˆ˜์ •ํ•ด์•ผํ•˜๋Š” ์ƒํ™ฉ์ด ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.
    ๋ณธ ์ฝ”๋“œ๋ž‘ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ์˜ ์˜์กด์„ฑ์ด ํฐ๊ฑฐ ๊ฐ™์€๋ฐ, ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๊ฐ€ ๋ณ€๊ฒฝ์— ์œ ์—ฐํ•˜๊ฒŒ๋” ์ž‘์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ์„๊นŒ์š”?

  3. ์ฝ”๋“œ ์ˆ˜์ •
    ์ด๋ฏธ ์‚ฌ์šฉ์ค‘์ธ ์„œ๋น„์Šค์—์„œ๋Š” ์ด์™€ ๊ฐ™์ด ๋„๋ฉ”์ธ์„ ๋Œ€๊ฑฐ ์ˆ˜์ •ํ•˜๋Š” ๊ณผ์ •์ด ์–ด๋ ค์šธ๊ฑฐ ๊ฐ™์€๋ฐ, ๋Œ€๊ฑฐ ์ˆ˜์ •์ด ํ•„์š”ํ•  ๊ฒฝ์šฐ ์–ด๋–ป๊ฒŒ ํ•ด์•ผํ•˜๋Š”์ง€ ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค.
    (ํ•˜๋‚˜๋ฅผ ๊ณ ์น˜๋ฉด ์—ฌ๋Ÿฌ๊ฐœ๊ฐ€ ์—๋Ÿฌ๋‚˜๋Š” ์ƒํ™ฉ์ด๋‹ค ๋ณด๋‹ˆ, ์ €๋Š” ์ „๋ถ€ ์ฃผ์„ํ•ด๋†“๊ณ  ์ฒ˜์Œ๋ถ€ํ„ฐ ํ•˜๋‚˜์”ฉ ์ฃผ์„์„ ํ•ด์ œํ•˜๊ณ  ๋ฌธ์ œํ•ด๊ฒฐํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ๋ฆฌํŒฉํ† ๋งํ–ˆ์Šต๋‹ˆ๋‹ค.)

*ํ”ผ๋“œ๋ฐฑ์„ ๋ฐ˜์˜ํ•˜๋Š” ๊ณผ์ •์—์„œ ๋„๋ฉ”์ธ ์žฌ๊ตฌ์„ฑ์ด ํ•„์š”ํ•˜๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ๋ฆฌํŒฉํ† ๋ง ๊ณผ์ •์—์„œ ๋งŽ์€ ํŒŒ์ผ์ด ๋ฐ”๋€Œ์—ˆ์Šต๋‹ˆ๋‹ค.๐Ÿฅฒ
*๊นƒ์„ ์ œ๋Œ€๋กœ ๋ชป ๋งŒ์ ธ์„œ, ์‚ฌ์ดํด 1์˜ ์ปค๋ฐ‹ ๋‚ด์šฉ๋„ ์ „๋ถ€ ๋œจ๋Š” ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. (๋ณด๊ธฐ ํž˜๋“œ์‹ค๊ฑฐ ๊ฐ™์•„์„œ ์ฃ„์†กํ•ฉ๋‹ˆ๋‹ค..)
*์‚ฌ์ดํด 1์—์„œ ๋‹ฌ์•„์ฃผ์‹  ๋ฆฌ๋ทฐ ๋‹ต๊ธ€์€ 14์ผ(ํ† )๋‚ด๋กœ ์ž‘์„ฑํ•ด๋‘๊ฒ ์Šต๋‹ˆ๋‹ค!

์‚ฌ์ดํด 1์˜ PR

๋งํฌ: #956


๋ฏธ์…˜ ์ค‘ ๊ธฐ๋ก

1. ๊ธฐ๋Šฅ ์ถ”๊ฐ€๋กœ ์ธํ•ด ์ˆ˜์ •ํ•œ ์œ„์น˜ ๊ฐœ์ˆ˜

๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•˜๋Š” ๊ณผ์ •์—์„œ ํ˜„์žฌ ๊ตฌ์กฐ๋กœ ํ™•์žฅํ•˜๊ธฐ์— ์–ด๋ ค์›€์ด ์žˆ์—ˆ๋‹ค.
๊ทธ๋ž˜์„œ ๋Œ€๋ถ€๋ถ„์˜ ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์„ ๋„๋ฉ”์ธ ์•ˆ์œผ๋กœ ๋„ฃ์–ด์„œ, ๋ณ€๊ฒฝ์— ์œ ์—ฐํ•˜๋„๋ก ๋„๋ฉ”์ธ์„ ์žฌ๊ตฌ์„ฑํ•˜์˜€๋‹ค.

1)BlackjackResult์‚ญ์ œ
์›๋ž˜๋Š” BlackjackResult์—์„œ ์ŠนํŒจ์™€ ๊ฐ™์€ ๊ฒŒ์ž„์˜ ๊ธฐ๋ก์„ ์ €์žฅํ–ˆ๋Š”๋ฐ,
๋ฐฐํŒ… ์ƒ๊ธˆ์ด๋ผ๋Š” ๊ฒฐ๊ณผ๊ฐ€ ํ•˜๋‚˜ ๋” ์ถ”๊ฐ€ ๋˜๋ฉด์„œ, ์ถœ๋ ฅ ๊ฒฐ๊ณผ(response)๋ฅผ ๋„๋ฉ”์ธ์œผ๋กœ ๊ฐ–๋Š” ๊ฒƒ์€ ํ™•์žฅ์„ฑ์ด ์•ˆ์ข‹๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ๋‹ค.
๊ทธ๋ž˜์„œ BlackjackResult๋ฅผ ์—†์• ๊ณ , Game์ด๋ผ๋Š” ๋„๋ฉ”์ธ์—์„œ ๊ทธ๋•Œ๊ทธ๋–„ ์›ํ•˜๋Š” ๊ฒฐ๊ณผ๋ฅผ ๋ฐ˜ํ™˜ํ•  ์ˆ˜ ์žˆ๋„๋ก ๋ฉ”์„œ๋“œ๋งŒ ๊ตฌํ˜„ํ•˜์˜€๋‹ค.

2)Deck ๋„๋ฉ”์ธ ์ถ”๊ฐ€, Cards ์ผ๊ธ‰ ์ปฌ๋ ‰์…˜ ์ˆ˜์ •
Cards๋ผ๋Š” ์ผ๊ธ‰ ์ปฌ๋ ‰์…˜์„ ์นด๋“œ ์ „์ฒด(52์žฅ)๋ฅผ ํƒ€๊นƒ์œผ๋กœ ์‚ฌ์šฉํ–ˆ๋‹ค ๋ณด๋‹ˆ, Player๊ฐ€ ๊ฐ–๋Š” ์นด๋“œ ๋”๋ฏธ๋Š” Cards๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ๋ชปํ–ˆ๋‹ค.
์ „์ฒด ์นด๋“œ๋Š” ๋žœ๋ค ์ƒ์„ฑ, ์นด๋“œ ์ถ”์ถœ ๊ธฐ๋Šฅ์— ๋Œ€ํ•œ ์ฑ…์ž„๋งŒ ๊ฐ€์ง€๊ธฐ ๋•Œ๋ฌธ์— ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๊ฐ€์ง€๋Š” ์นด๋“œ ๋ญ‰์น˜ Cards์™€ ๋”ฐ๋กœ ๋ถ„๋ฆฌํ•˜๋Š” ๊ฒƒ์ด ๋‚ซ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ๋‹ค.
๊ทธ๋ž˜์„œ Player๊ฐ€ ์†Œ์œ ํ•œ ์นด๋“œ ๋ญ‰์น˜๋ฅผ Cards๋ผ๋Š” ์ผ๊ธ‰ ์ปฌ๋ ‰์…˜์œผ๋กœ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด, ์ „์ฒด ์นด๋“œ๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” Deck์ด๋ผ๋Š” ๋„๋ฉ”์ธ์„ ์ถ”๊ฐ€ํ•˜์˜€๋‹ค.
CardGenerator๋ฅผ ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ ๋ฐ›์•„์„œ ์ „์ฒด ์นด๋“œ ์ƒ์„ฑ์— ๊ด€ํ•ด์„œ Deck์—์„œ ์ฒ˜๋ฆฌํ•˜๋„๋ก ํ•˜์˜€๋‹ค.
์นด๋“œ ์ƒ์„ฑ์„ ์ €๋ฒˆ์— ์ธํ„ฐํŽ˜์ด์Šค๋กœ ํ•ด์„œ ๋ถ„๋ฆฌํ•˜๋‹ˆ ์ด๋ถ€๋ถ„์— ๋Œ€ํ•œ ์ˆ˜์ •์€ ํŽธ๋ฆฌํ–ˆ๋‹ค.
(CardGenerator๋ฅผ ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ ๋ฐ›์•„์„œ ๋ฉ”์„œ๋“œ๋กœ๋งŒ ํ˜ธ์ถœํ•˜๋ฉด ๋˜๋‹ˆ๊นŒ.)

4)Game ๋„๋ฉ”์ธ ์ถ”๊ฐ€, Dealer ๋„๋ฉ”์ธ ์‚ญ์ œ
Game์— ๋Œ€ํ•œ ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์ด๋‚˜ ๊ทœ์น™๋“ค์ด Player, Dealer, Cards ๋“ฑ์— ํฉ์–ด์ ธ์žˆ์–ด ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ž‘์„ฑ์— ์–ด๋ ค์›€์ด ์žˆ์—ˆ๋‹ค.
๋”ฐ๋ผ์„œ, ๋ธ”๋ž™์žญ ๊ฒŒ์ž„ ๊ทœ์น™์— ๋Œ€ํ•œ ๋ฉ”์„œ๋“œ๋ฅผ ๋ชจ์•„๋‘๊ธฐ ์œ„ํ•ด Game์ด๋ผ๋Š” ๋„๋ฉ”์ธ์„ ์ถ”๊ฐ€ํ•˜์˜€๋‹ค.

Game์„ ์ถ”๊ฐ€ํ•˜๊ณ  ๋‚˜๋‹ˆ Dealer์˜ ํ•„๋“œ๋Š” Player์™€ ๊ฒน์น˜๊ณ , Dealer์˜ ๊ทœ์น™์€ Game์—์„œ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ์œผ๋กœ ๋ณด์•˜๋‹ค.
(16์ดํ•˜์ด๋ฉด ์นด๋“œ๋ฅผ ๋” ๋ฐ›๋Š”๋‹ค๋Š” Dealer์˜ ๊ทœ์น™์€ ๊ฒŒ์ž„์˜ ๊ทœ์น™์ด๋ผ๊ณ  ๋ณผ ์ˆ˜๋„ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.)
Game๊ณผ Dealer๋Š” ํ•ญ์ƒ 1๋Œ€ 1๋กœ ์กด์žฌํ•˜๊ธฐ ๋–„๋ฌธ์—, ๊ฐ์ฒด ์ƒ์„ฑ-์†Œ๋ฉธ ์ฃผ๊ธฐ๊ฐ€ ๊ฐ™๋‹ค๊ณ  ํŒ๋‹จํ•˜์—ฌ ๊ด€๋ จ ๋กœ์ง์„ Game์— ๋‘์—ˆ๋‹ค.

์ถ”๊ฐ€๋กœ Dealer๋Š” ๊ฒŒ์ž„์„ ๋งŒ๋“ค ๋•Œ ์™ธ๋ถ€์—์„œ ์ฃผ์ž…ํ•ด์ฃผ๋Š” ๋ฐฉ์‹์œผ๋กœ ํ–ˆ๋‹ค. ๊ทธ๋ž˜์•ผ GameTest์—์„œ Dealer์˜ ์นด๋“œ๋ฅผ ์กฐ์ž‘ํ•ด์ค„ ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.
ํ…Œ์ŠคํŠธ๋ฅผ ์ž‘์„ฑํ•˜๋ฉฐ ์˜์กด์„ฑ์„ ์ค„์ด๋Š” ๋ฐฉํ–ฅ์œผ๋กœ ๊ฐœ๋ฐœ์„ ํ•˜๊ฒŒ ๋˜์—ˆ๋‹ค.

2. ์‚ฌ์ดํด1 ๋•Œ๋ณด๋‹ค ์ˆ˜์ • ๋ฒ”์œ„๊ฐ€ ์ค„์—ˆ๋Š”๊ฐ€/๋Š˜์—ˆ๋Š”๊ฐ€

์‚ฌ์ดํด 1์—์„œ ๋‹จํŽธ์ ์ธ ๊ฒฐ๊ณผ ์ถœ๋ ฅ์—๋งŒ ์ง‘์ค‘ํ•ด์„œ ๋„๋ฉ”์ธ์„ ์„ค๊ณ„ํ•ด์„œ ๊ทธ๋Ÿฐ์ง€, ๊ธฐ๋Šฅ ์ถ”๊ฐ€๋ฅผ ์œ„ํ•ด ์ฝ”๋“œ ๋ณ€๊ฒฝ์ด ๋ง‰๋ง‰ํ•˜๊ณ  ์–ด๋ ค์› ๋‹ค.
๊ทธ๋ž˜์„œ ๋„๋ฉ”์ธ์„ ์žฌ๊ตฌ์„ฑํ•˜์˜€๊ธฐ ๋•Œ๋ฌธ์—, ์‚ฌ์ดํด1 ๋•Œ๋ณด๋‹ค ์ˆ˜์ • ๋ฒ”์œ„๊ฐ€ ํ›จ์”ฌ ์ปธ๋‹ค.
๋ณ€๊ฒฝ๋œ ๊ตฌ์กฐ์—์„œ๋Š” ๊ธฐ๋Šฅ ์ถ”๊ฐ€ ์‹œ Game์— ์ฝ”๋“œ๋ฅผ ์ถ”๊ฐ€ํ•˜๋ฉด ๋˜๊ธฐ ๋•Œ๋ฌธ์—, ์ฝ”๋“œ ๋ณ€๊ฒฝ์ด ์ ์„ ๊ฒƒ์œผ๋กœ ์˜ˆ์ƒ๋œ๋‹ค.

3. ๊ทœ์น™ ์ ์šฉ์œผ๋กœ ๋ณ€๊ฒฝํ•œ ์ฝ”๋“œ 1๊ณณ

(If-Then) ํ•˜๋“œ์ฝ”๋”ฉ๋œ ๊ฐ’์ด ๋ณด์ธ๋‹ค๋ฉด, โ†’ ์ƒ์ˆ˜ํ™”ํ•œ๋‹ค.
๋„๋ฉ”์ธ์œผ๋กœ ๋กœ์ง์„ ์ด๋™ํ•˜๋ฉด์„œ, ์ƒ์ˆ˜๋„ ์ ์ ˆํ•œ ๋„๋ฉ”์ธ์œผ๋กœ ์ด๋™ํ•ด ์‘์ง‘์„ฑ ์žˆ๊ฒŒ ์ˆ˜์ •ํ•˜์˜€๋‹ค.

(If-Then) ๊ฐ™์€ ๊ฐ์ฒด๋ฅผ ๋‹ค๋ฃจ๋Š” ํด๋ž˜์Šค์—ฌ๋„ ๋ชฉ์ ์ด ๋‹ค๋ฅด๋ฉด, โ†’ ํด๋ž˜์Šค๋ฅผ ๋ถ„๋ฆฌํ•œ๋‹ค. (e.g. Cards -> Deck, Hand)
Cards๋ฅผ Cards(Player ์†Œ์œ  ์นด๋“œ), Deck(์ „์ฒด์นด๋“œ)์œผ๋กœ ๋‚˜๋ˆ„์–ด์„œ ๋ฆฌํŒฉํ† ๋งํ•˜์˜€๋‹ค.

4. ํ…Œ์ŠคํŠธ๊ฐ€ ์„ค๊ณ„๋ฅผ ๋„์šด ์ˆœ๊ฐ„ 1ํšŒ

๊ฒŒ์ž„ ๊ทœ์น™์— ๋Œ€ํ•œ ํ…Œ์ŠคํŠธ๋ฅผ ์ง„ํ–‰ํ•˜๋ ค๊ณ  ํ–ˆ๋Š”๋ฐ,
์ด๋Ÿฐ ๊ทœ์น™์ด Player, Dealer, Cards ๋“ฑ ์—ฌ๋Ÿฌ ๋„๋ฉ”์ธ์— ๊ฑธ์ณ์„œ ์กด์žฌํ•˜๋Š” ๊ฒƒ์ด ๋ถˆํŽธํ–ˆ๋‹ค.
ํ…Œ์ŠคํŠธ ๊ตฌํ˜„์„ ํ†ตํ•ด ๋„๋ฉ”์ธ์˜ ์ฑ…์ž„ ๋ถ„๋ฆฌ์— ๋Œ€ํ•œ ์žฌ๊ตฌ์„ฑ ํ•„์š” ์‹ ํ˜ธ๋ฅผ ํฌ์ฐฉํ•  ์ˆ˜ ์žˆ์–ด์„œ ์„ค๊ณ„์— ๋„์›€์ด ๋˜์—ˆ๋‹ค.

์ฒดํฌ ๋ฆฌ์ŠคํŠธ

  • ๋ฏธ์…˜์˜ ํ•„์ˆ˜ ์š”๊ตฌ์‚ฌํ•ญ์„ ๋ชจ๋‘ ๊ตฌํ˜„ํ–ˆ๋‚˜์š”?
  • Gradle test๋ฅผ ์‹คํ–‰ํ–ˆ์„ ๋•Œ, ๋ชจ๋“  ํ…Œ์ŠคํŠธ๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ํ†ต๊ณผํ–ˆ๋‚˜์š”?
  • ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์ •์ƒ์ ์œผ๋กœ ์‹คํ–‰๋˜๋‚˜์š”?

์‚ฌ์ดํด 2์˜ ์ˆ˜์ •์‚ฌํ•ญ (260316)

  • ๋‹จ์ผ ๋ฐ˜ํ™˜ ๋žŒ๋‹ค์‹์—์„œ ์ค‘๊ด„ํ˜ธ ๋ฐ return ์ œ๊ฑฐ
  • OutputView์—์„œ ๋„๋ฉ”์ธ ์ •์ฑ… ์ œ๊ฑฐ (๋ฆฌ๋ทฐ์–ด ํ™•์ธ ํ•„์š”!)
  • Card์—์„œ Ace ํŒ๋‹จ ์—ฌ๋ถ€ ๋ฉ”์„œ๋“œ ์ˆ˜์ •(์บก์Аํ™”) - get ํ•˜์ง€ ์•Š๊ณ , isAce๋กœ boolean์„ return
  • ๊ธฐ๋Šฅ ์ฑ…์ž… ๋ถ„๋ฆฌ (๊ฒŒ์ž„ ํŒ๋‹จ ์ฑ…์ž„, ๋ˆ ๊ณ„์‚ฐ ์ฑ…์ž„)
  • ํ…Œ์ŠคํŠธ๋งŒ์„ ์œ„ํ•œ ๋ฉ”์„œ๋“œ ์‚ญ์ œ
  • ํ…Œ์ŠคํŠธ ์œ ํ‹ธ์„ ์ด์šฉํ•ด ์ค‘๋ณต ์ œ๊ฑฐ (for ์œ ์—ฐํ•œ ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•จ)

์‚ฌ์ดํด 2์˜ ์ˆ˜์ •์‚ฌํ•ญ2 (260318)

  • allMatch์— ๋นˆ ๋ฆฌ์ŠคํŠธ๊ฐ€ ํ•ญ์ƒ true๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ๋ฌธ์ œ ์ˆ˜์ • (Players)
  • ๋ฉ”์„œ๋“œ์—์„œ ์‚ฌ์šฉ์•ˆํ•˜๋Š” ํŒŒ๋ผ๋ฏธํ„ฐ ์ œ๊ฑฐ (Game)
  • ์ž๋ฐ” ๋„ค์ด๋ฐ ์ปจ๋ฒค์…˜ - ์นด๋ฉœ ์ผ€์ด์Šค ์ ์šฉ (OutputView)
  • ์™ธ๋ถ€์—์„œ betMoney๋กœ ๊ฐ’ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ๋Š” ๋ฌธ์ œ ์ˆ˜์ • (Player)
  • ๋ฐฐํŒ… ์ ์ˆ˜ ๊ณ„์‚ฐ ์ฑ…์ž„ ๋ถ„๋ฆฌ๋ฅผ ์œ„ํ•ด Betting ๋„๋ฉ”์ธ ์ƒ์„ฑ(Player์˜ ์ฑ…์ž„ ๋ถ„๋ฆฌ)
  • ๋ถˆ๋ณ€ ์ปฌ๋ ‰์…˜ ๋ฐฉ์–ด์  ๋ณต์‚ฌ ์ ์šฉ
  • ๋ž˜ํผ ํƒ€์ž…์—์„œ ๋ถˆํ•„์š”ํ•˜๊ฒŒ ์›์‹œ๊ฐ’์œผ๋กœ ๋ณ€๊ฒฝํ•˜๋Š” ๋ฌธ์ œ ์ˆ˜์ • (OutputView)
  • Dealer ๋„๋ฉ”์ธ ์ƒ์„ฑ ๋ฐ ์ฑ…์ž„ ๋ถ„๋ฆฌ

Player์˜ ์ฑ…์ž„์„ ์ค„์ด๊ธฐ ์œ„ํ•ด Betting๊ณผ Dealer ๋„๋ฉ”์ธ์„ ์ƒ์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค.
๋ˆ ๊ณ„์‚ฐ์— ๋Œ€ํ•œ ์ฑ…์ž„์„ Betting์—๊ฒŒ, ๋”œ๋Ÿฌ์— ๋Œ€ํ•œ ์ฑ…์ž„์„ Dealer์—๊ฒŒ ๋ถ€์—ฌํ•ด, ์ฑ…์ž„์„ ๋ถ„๋ฆฌํ–ˆ์Šต๋‹ˆ๋‹ค.

ParkJiYeoung8297 and others added 30 commits March 5, 2026 10:32
Copy link

@jurlring jurlring left a comment

Choose a reason for hiding this comment

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

์•„ํ‹ฐ ์•ˆ๋…•ํ•˜์„ธ์š” ๐Ÿฐ
์งˆ๋ฌธ ์ฃผ์‹  ๋ถ€๋ถ„์— ๋Œ€ํ•œ ์ƒ๊ฐ๋“ค๊ณผ ์ฝ”๋ฉ˜ํŠธ ๋ช‡๊ฐ€์ง€ ๋‚จ๊ฒจ๋‘์—ˆ์–ด์š”.
์‹œ๊ฐ„ ๊ดœ์ฐฎ์œผ์‹ค ๋•Œ ํ™•์ธํ•ด์ฃผ์„ธ์š”~!
์ฆ๊ฑฐ์šด ์ฃผ๋ง ๋˜์„ธ์š”~~

Comment on lines +63 to +64
public void betMoney(int money) {
bettingScore = money;

Choose a reason for hiding this comment

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

ํ”Œ๋ ˆ์ด์–ด ์ƒ์„ฑ ์‹œ์ ์— bettingScore๋ฅผ ์ดˆ๊ธฐํ™” ํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ์—†์„๊นŒ์š”? ๊ทธ๋Ÿผ ์žฅ์ ์€ ์–ด๋–ค๊ฒŒ ์žˆ์„๊นŒ์š”?

Copy link
Author

Choose a reason for hiding this comment

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

ํ˜„์žฌ bettingScore๋Š” ์ƒ์„ฑ ์‹œ์ ์— 0์œผ๋กœ ์ดˆ๊ธฐํ™”ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๐Ÿ™‚

ํ”Œ๋ ˆ์ด์–ด ์ƒ์„ฑ ์‹œ์ ์— bettingScore๋ฅผ ์ดˆ๊ธฐํ™” ํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ์—†์„๊นŒ์š”? ๊ทธ๋Ÿผ ์žฅ์ ์€ ์–ด๋–ค๊ฒŒ ์žˆ์„๊นŒ์š”?

์ƒ์„ฑํ•  ๋•Œ, ์ดˆ๊ธฐํ™”๋ฅผ ํ•ด์ค€๋‹ค๋ฉด ๊ฐ์ฒด๊ฐ€ ํ•„์š”ํ•œ ๊ฐ’์„ ๊ฐ€์ง€๊ณ  ์žˆ๊ฒŒ ๋˜์–ด ๊ฐ์ฒด ์•ˆ์ •์„ฑ์ด ๋†’์•„์งˆ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค!

๋‹ค๋งŒ ํ˜„์žฌ ์ž…๋ ฅ ๋ฐ›๋Š” ๊ตฌ์กฐ์—์„œ๋Š” controller์—์„œ List<String> names๋ฅผ ๋Œ๋ ค์„œ betting score๋ฅผ ๋ฐ›๊ณ ,
Map์œผ๋กœ {์ด๋ฆ„ : betting score}๋ฅผ ์ €์žฅํ•ด์„œ ๋„๋ฉ”์ธ ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ ๋„˜๊ฒจ์ค˜์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์—,
๋จผ์ € Player๋ฅผ ์ƒ์„ฑํ•˜๊ณ , ์ดํ›„ betScore๋กœ ์„ธํŒ…ํ•ด์ฃผ๋Š” ๋ฐฉ์‹์„ ์ƒ๊ฐํ–ˆ์Šต๋‹ˆ๋‹ค.

Choose a reason for hiding this comment

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

betting score๋Š” ํ”Œ๋ ˆ์ด์–ดํ•œํ…Œ ์ค‘์š”ํ•œ ๊ฐ’์ธ๋ฐ, betMoney๋กœ ์™ธ๋ถ€์— ์ˆ˜์ •์ด ๊ฐ€๋Šฅํ•œ ๋ฉ”์„ธ์ง€๋ฅผ ๋…ธ์ถœํ•˜๊ณ  ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ์–ด์š”.

controller์—์„œ List names๋ฅผ ๋Œ๋ ค์„œ betting score๋ฅผ ๋ฐ›์œผ๋ฉด ์–ด๋–ค ๋ฌธ์ œ๊ฐ€ ์žˆ์–ด์š”?

Copy link
Author

Choose a reason for hiding this comment

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

์—‡ List<String> name์„ for๋ฌธ ๋Œ์•„์„œ ๋ฐฐํŒ…๊ธˆ์•ก์„ ์ž…๋ ฅ ๋ฐ›๊ณ , Map์œผ๋กœ ๋„˜๊ฒจ์ค˜์•ผํ•œ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ๋Š”๋ฐ,
createPlayer๋ฅผ ๋งŒ๋“ค์–ด์„œ ๋ฐฐํŒ…๊ธˆ์•ก ์ž…๋ ฅ๋ฐ›์„ ๋•Œ๋งˆ๋‹ค Player๋ฅผ ์ƒ์„ฑํ•ด์ค˜๋„ ๋  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.
(createPlayers()์—์„œ Player๋„ ์ƒ์„ฑํ•˜๊ณ , Players๋„ ์ƒ์„ฑํ•˜๋Š” ๋‘ ๊ฐ€์ง€ ์ฑ…์ž„์„ ๊ฐ€์ง€๊ณ  ์žˆ์—ˆ๋„ค์š”..๐Ÿ˜…)

image

Player์—์„œ Betting ํ•„๋“œ๋ฅผ final๋กœ ๋‘๊ณ  ์ƒ์„ฑํ•  ๋‹น์‹œ์— ๊ฐ’์„ ๋„ฃ์–ด์ฃผ๋Š” ๋ฐฉ์‹์œผ๋กœ ์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค!
๋ฐฐํŒ… ๊ธˆ์•ก ๊ด€๋ จํ•ด์„œ ์ˆ˜์ •ํ•  ์ˆ˜ ์—†๋„๋ก ํ–ˆ๊ณ , Betting ๋„๋ฉ”์ธ ๋‚ด๋ถ€์—์„œ ์ตœ์ข… ์ˆ˜์ต์„ ๊ณ„์‚ฐํ•˜๋Š” ์ฑ…์ž„์„ ๋ถ€์—ฌํ–ˆ์Šต๋‹ˆ๋‹ค.

public class Player {

    private final Cards cards;
    private final String name;
    private final Betting betting;

    public Player(String name, Betting betting) {
        this.name = name;
        this.betting = betting;
        this.cards = new Cards();
    }

Comment on lines +28 to 53
public MatchCase calculateMatchCase(int dealerTotal) {
if (cards.getFinalScore() > dealerTotal) {
return MatchCase.WIN;
}
if (cards.getFinalScore() == dealerTotal) {
return MatchCase.DRAW;
}
if (cards.getFinalScore() < dealerTotal) {
return MatchCase.LOSE;
}
throw new IllegalArgumentException("[ERROR] ์ผ์น˜ํ•˜๋Š” enum์ด ์—†์Šต๋‹ˆ๋‹ค.");
}

private int calculateAceScore() {
if (!isAceExist() || calculateScore() > 11) {
return ACE_ADDITION_NONE_SCORE;
public void calculateMoney(MatchCase matchCase, boolean isDealerBlackjack) {
if (cards.isBlackjack() && !isDealerBlackjack) {
bettingScore = (int) ((int) bettingScore * Game.BLACKJACK_BONUS);
return;
}
if (matchCase.equals(MatchCase.LOSE)) {
loseMoney();
return;
}

if (matchCase.equals(MatchCase.WIN)) {
return;
}

Choose a reason for hiding this comment

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

ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๋„ˆ๋ฌด ๊ณผ๋„ํ•œ ์ฑ…์ž„์„ ๊ฐ€์ง„๊ฒŒ ์•„๋‹๊นŒ์š”~?
๋‹จ์ผ์ฑ…์ž„์›์น™์„ ์ง€ํ‚ค๊ณ  ์žˆ์ง€ ์•Š์•„๋ณด์—ฌ์š”.

Copy link
Author

Choose a reason for hiding this comment

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

๋ฉ”์„œ๋“œ๋ฅผ ์ด์šฉํ•ด์„œ ๋ถ„๋ฆฌํ•ด, ํ•˜๋‚˜์˜ ์ฑ…์ž„์„ ์ง€๋„๋ก ์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.

ํŒ๋‹จ ๋กœ์ง๋งŒ ๋‚จ๊ฒจ๋‘๊ณ  ๋ˆ ๊ณ„์‚ฐํ•˜๋Š” ๋ฉ”์„œ๋“œ๋ฅผ ๋ถ„๋ฆฌํ–ˆ๋Š”๋ฐ,
์ด์™€ ๊ฐ™์ด ์ˆ˜์ •ํ•˜๋ฉด ์ฑ…์ž„ ๋ถ„๋ฆฌ๊ฐ€ ๋˜์—ˆ๋‹ค๊ณ  ํ•  ์ˆ˜ ์žˆ์„๊นŒ์š”? (์Šน๋ถ€ ํŒ๋‹จ ์ฑ…์ž„, ๋ˆ ๊ณ„์‚ฐ ์ฑ…์ž„)

    public void calculateMoney(MatchCase matchCase, boolean isDealerBlackjack) {
        if (cards.isBlackjack() && !isDealerBlackjack) {
            gainMoney();
            return;
        }
        if (matchCase.equals(MatchCase.LOSE)) {
            loseMoney();
            return;
        }
        if (matchCase.equals(MatchCase.WIN)) {
            return;
        }
        resetMoneyZero();
    }

    private void resetMoneyZero() {
        bettingScore = 0;
    }

    private void gainMoney() {
        bettingScore = (int) ((int) bettingScore * Game.BLACKJACK_BONUS);
    }

    private void loseMoney() {
        int minusScore = bettingScore * 2;
        bettingScore -= minusScore;
    }

Choose a reason for hiding this comment

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

๋ฉ”์„œ๋“œ๋ฅผ ๋ถ„๋ฆฌํ•œ ๊ฒƒ๊ณผ ์ฑ…์ž„์ด ๋ถ„๋ฆฌ๋˜์—ˆ๋‹ค๋Š” ๋‹ค๋ฅธ ๊ฒƒ ๊ฐ™์•„์š”!
๋ง์”€์ฃผ์‹ ๋Œ€๋กœ๋ผ๋ฉด ์Šน๋ถ€ ํŒ๋‹จ ์ฑ…์ž„์€ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๊ฐ€์ง€๋Š”๋ฐ, ๊ธฐ์กด์—๋„ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๊ฐ€์ง„ ์ฑ…์ž„์ด ์žˆ์ง€์š”..! ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์นด๋“œ๋„ ๋“ค๊ณ ์žˆ๊ณ , ๋ฒ ํŒ…๊ธˆ์•ก๋„ ๋“ค๊ณ  ์žˆ๊ณ , ์ŠนํŒจ๋„ ํŒ๋‹จํ•˜๋Š”๋ฐ ๋‹จ์ผ ์ฑ…์ž„์›์น™์„ ์ง€์ผฐ๋‹ค๊ณ  ๋ณผ ์ˆ˜ ์žˆ์„๊นŒ์š”?!
์นด๋“œ๋ฅผ ๊ฐ€์ง„ ์ฐธ๊ฐ€์ž์™€ ๋ฒ ํŒ…์„ ํ•˜๋Š” ์ฐธ๊ฐ€์ž๋ฅผ ๋‚˜๋ˆ„๋ฉด ์–ด๋•Œ์š”?

Copy link
Author

Choose a reason for hiding this comment

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

๋‹จ์ผ ์ฑ…์ž„ ์›์น™์„ ๋ฉ”์„œ๋“œ ๋‹จ์œ„์—์„œ๋งŒ ์‹ ๊ฒฝ์ผ๋Š”๋ฐ, ๋„๋ฉ”์ธ ๋‹จ์œ„์—์„œ๋„ ๊ณ ๋ คํ•ด์•ผ๊ฒ ๋„ค์š”. ๐Ÿ™‚
Dealer, Betting ๋„๋ฉ”์ธ์„ ์ถ”๊ฐ€๋กœ ์ƒ์„ฑํ•ด์„œ ์ฑ…์ž„์„ ๋ถ„๋ฆฌํ•ด๋ดค์Šต๋‹ˆ๋‹ค!

์นด๋“œ๋งŒ ๊ฐ€์ง„ ์ฐธ๊ฐ€์ž : Dealer
๋ฒ ํŒ… ํ•˜๋Š” ์ฐธ๊ฐ€์ž : Player
๋ฒ ํŒ…๊ธˆ์•ก ๊ณ„์‚ฐ : Betting

Choose a reason for hiding this comment

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

๋‹จ์ผ ์ฑ…์ž„ ์›์น™์€ ๋กœ๋ฒ„ํŠธ ๋งˆํ‹ด(Robert C. Martin)์ด ์ œ์•ˆํ•œ SOLID ์›์น™์ค‘์— ํ•˜๋‚˜๋กœ ๊ฐ์ฒด ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ๋ฐ ์„ค๊ณ„์—์„œ ์œ ์ง€๋ณด์ˆ˜๊ฐ€ ์‰ฝ๊ณ , ํ™•์žฅ ๊ฐ€๋Šฅํ•˜๋ฉฐ, ๊ฒฌ๊ณ ํ•œ ์ฝ”๋“œ๋ฅผ ๋งŒ๋“ค๊ธฐ ์œ„ํ•œ 5๊ฐ€์ง€ ํ•ต์‹ฌ ์›์น™์ค‘ ํ•˜๋‚˜์ธ๋ฐ์š”!
๊ทธ๋ ‡๋‹ค๋ณด๋‹ˆ ๋ฉ”์„œ๋“œ ๋‹จ์œ„๊ฐ€ ์•„๋‹ˆ๋ผ ๊ฐ์ฒด ๋‹จ์œ„๋กœ ์ง€์ผœ์•ผํ•ฉ๋‹ˆ๋‹ค.
์ง€๊ธˆ ๋‚˜๋ˆ ์ฃผ์‹ ๊ฑด Betting์˜ ์›์‹œ๊ฐ’์„ ํฌ์žฅํ•ด์ฃผ์‹  ๊ฒƒ ๊ฐ™๊ณ , ์•„์ง ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์นด๋“œ๋„ ๋“ค๊ณ ์žˆ๊ณ , ๋ฒ ํŒ…๊ธˆ์•ก์„ ๊ณ„์‚ฐํ•˜๊ณ , ์ŠนํŒจ๋„ ํŒ๋‹จํ•˜๊ณ  ์žˆ๋Š” ๊ฒƒ์œผ๋กœ ๋ณด์ด๋Š”๋ฐ์š”.
์ŠนํŒจ๋ฅผ MatchCase๊ฐ€ ํŒ๋‹จํ•˜๋ฉด ์•ˆ๋˜๋‚˜์š”?
๋ฒ ํŒ…๊ธˆ์•ก์„ ๊ณ„์‚ฐ์„ ๊ผญ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ํ•ด์•ผํ• ๊นŒ์š”?

๋‹จ์ผ ์ฑ…์ž„ ์›์น™์„ ์ ์šฉํ•˜๊ธฐ ์ „์— ๋‹จ์ผ ์ฑ…์ž„ ์›์น™์ด ๋ญ”์ง€ ๋‹จ์ผ ์ฑ…์ž„ ์›์น™์„ ์ง€ํ‚ค๋ฉด ์–ด๋–ค ์žฅ์ ์ด ์žˆ์„์ง€ ๊ณ ๋ฏผํ•ด๋ณด์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค! :)

import domain.dto.MatchResultDto;
import domain.enums.MatchCase;

public final class OutputView {

Choose a reason for hiding this comment

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

Dealer๋ฅผ ํ”Œ๋ ˆ์ด์–ด๋กœ ์ƒ์„ฑํ•˜๊ฒŒ ๋ณ€๊ฒฝ๋˜์–ด, view๋‹จ์—์„œ ๋„๋ฉ”์ธ ์ •์ฑ…์— ๋Œ€ํ•œ ๊ตฌํ˜„์ด ๋“ค์–ด๊ฐ€๋Š” ๊ฒƒ ๊ฐ™์•„์š” ๐Ÿ˜ฟ

Copy link
Author

Choose a reason for hiding this comment

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

์ตœ๋Œ€ํ•œ ๋„๋ฉ”์ธ ๊ทœ์น™ ์—†์ด dto ๊ฐ’๋งŒ ๊บผ๋‚ด์™€์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๊ฒŒ๋” ์•„๋ž˜์˜ ์ฝ”๋“œ๋ฅผ ์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.
(before: ํ”Œ๋ ˆ์ด์–ด์˜ ์ดํ•ฉ์ด ๋”œ๋Ÿฌ ์ˆ˜์ต์ด๋ผ๋Š” ์ ์„ ์•Ž, after: dto์—์„œ ๋‹จ์ˆœํžˆ ๊ฐ’์„ ๊บผ๋‚ด์„œ ์ถœ๋ ฅํ•จ)
image

๋„๋ฉ”์ธ ์ •์ฑ…์— ๋Œ€ํ•œ ๊ตฌํ˜„์ด view์— ์žˆ๋‹ค๋Š” ๊ฒƒ์ด ์ž˜ ์ดํ•ด๊ฐ€ ์•ˆ๋˜๋Š”๋ฐ, ์ด๋Ÿฐ ์ ์„ ๋ง์”€ํ•˜์‹ ๊ฒŒ ๋งž์„๊นŒ์š”?
ํ˜น์‹œ ์•„๋‹ˆ๋ผ๋ฉด, ์กฐ๊ธˆ๋งŒ ๋” ๊ตฌ์ฒด์ ์œผ๋กœ ์„ค๋ช…ํ•ด์ฃผ์‹ค ์ˆ˜ ์žˆ์„๊นŒ์š”?๐Ÿฅฒ

<์ถ”๊ฐ€ ์งˆ๋ฌธ>
์ถ”๊ฐ€๋กœ OutputView์—์„œ ๋„๋ฉ”์ธ์„ ์ง์ ‘ getํ•˜๋Š”๊ฑด ์ง€์–‘ํ•ด์•ผํ•œ๋‹ค๊ณ  ๋ณด์ง€๋งŒ,
enum์€ ์ƒ์ˆ˜์˜ ์ง‘ํ•ฉ์ด๊ธฐ ๋•Œ๋ฌธ์— ๊ฐ’์„ ์ง์ ‘ getํ•˜๋Š” ๊ฒƒ์€ ๊ดœ์ฐฎ๋‹ค๊ณ  ์ƒ๊ฐํ•˜๋Š”๋ฐ
์ด ๋ถ€๋ถ„์— ๋Œ€ํ•ด์„œ ์ฃผ๋””๋Š” ์–ด๋–ป๊ฒŒ ์ƒ๊ฐํ•˜์‹œ๋Š”์ง€ ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค!

Choose a reason for hiding this comment

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

๋„ค ์ˆ˜์ •ํ•ด์ฃผ์‹  ๋ถ€๋ถ„์ด ๋งž์Šต๋‹ˆ๋‹ค~! ๋„๋ฉ”์ธ ์ •์ฑ…์— ๋Œ€ํ•œ ๊ตฌํ˜„์ด view์— ์žˆ์œผ๋ฉด ๋„๋ฉ”์ธ ์ •์ฑ…์ด ์‘์ง‘๋˜์–ด ์žˆ์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— view๊ฐ€ ๋ฐ”๋€” ๋•Œ๋งˆ๋‹ค ๊ณ ๋ คํ•ด์•ผํ•˜๊ณ , ๋†“์น˜๊ฒŒ๋˜๋ฉด ์žฅ์• ๋กœ ์ด๋ฃจ์–ด์ง€๊ฒ ์ฃ  ๐Ÿ˜ฑ ๊ทธ๋ ‡๋‹ค๋ฉด MVC๊ตฌ์กฐ๋กœ ์„ค๊ณ„ํ•˜์‹  ์˜๋ฏธ๋„ ์—†๊ตฌ์š”!

enum์€ ์ƒ์ˆ˜์˜ ์ง‘ํ•ฉ์ด๊ธฐ ๋•Œ๋ฌธ์— ๊ฐ’์„ ์ง์ ‘ getํ•˜๋Š” ๊ฒƒ์€ ๊ดœ์ฐฎ๋‹ค๋ผ๊ณ  ์ƒ๊ฐํ•˜์…จ๊ตฐ์š”~!
์ข‹์€ ์ ‘๊ทผ์ด์ง€๋งŒ displayCardContent์—์„œ card.getCardRank().getName() + card.getCardShape().getName() ์ด๋ ‡๊ฒŒ Card์˜ ๋‚ด๋ถ€ ๊ตฌ์กฐ๋ฅผ OutputView๊ฐ€ ์ง์ ‘ ์กฐํ•ฉํ•˜๊ณ  ์žˆ์–ด์š”! ๋งŒ์•ฝ ์นด๋“œ ํ‘œํ˜„ ๋ฐฉ์‹์ด ๋ฐ”๋€Œ๋ฉด OutputView๋ฅผ ์ˆ˜์ •ํ•ด์•ผ ํ•˜๋Š”๋ฐ, ์ด๊ฑด View์˜ ์ฑ…์ž„์ผ๊นŒ์š”?!

Copy link
Author

Choose a reason for hiding this comment

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

์ถœ๋ ฅ์— ๋Œ€ํ•œ ๊ฒƒ์€ View์˜ ์ฑ…์ž„์ด๋ผ๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค!๐Ÿ™‚

์ถœ๋ ฅ๊ณผ ๊ฐ™์€ ๊ฒฝ์šฐ์—๋Š” ์‚ฌ์šฉ์ž์˜ ์š”๊ตฌ์‚ฌํ•ญ์— ๋”ฐ๋ผ ๋นˆ๋ฒˆํ•˜๊ฒŒ ๋ฐ”๋€” ์ˆ˜ ์žˆ๋Š” ๊ฐ’์ด๋ผ,
์ด๋ฅผ ์ตœ๋Œ€ํ•œ presentation layer ๋‚ด์—์„œ ์ˆ˜ํ–‰ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.
(์ถœ๋ ฅ ์š”๊ตฌ์‚ฌํ•ญ ๋ณ€๊ฒฝ์œผ๋กœ ์ธํ•ด ๋„๋ฉ”์ธ์ด๋‚˜ ์„œ๋น„์Šค ์ฝ”๋“œ๊ฐ€ ๋ฐ”๋€Œ๋Š” ๊ตฌ์กฐ๋Š” ์œ„ํ—˜ํ•˜๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ์Šต๋‹ˆ๋‹ค.)

๋˜ํ•œ ์ถ”ํ›„ ์ž…๋ ฅ์ด ๋Š˜์–ด๋‚  ๋•Œ(์ฝ˜์†” ์ถœ๋ ฅ, ํŒŒ์ผ ์ถœ๋ ฅ), ์•„๋ž˜์˜ ์˜ˆ์‹œ์™€ ๊ฐ™์ด ์ถœ๋ ฅ ํ˜•์‹์— ๊ด€๋ จ๋œ ๊ฒƒ์„ ๊ฐ๊ฐ์˜ View์—์„œ ์ˆ˜ํ–‰ํ•˜๋Š” ๊ฒƒ์ด ์ฑ…์ž„ ๋ถ„๋ฆฌ์— ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

1) ConsoleOutputView :

System.out.printf("%s   %s",card.getCardRank().getName(), card.getCardShape().getName());

์ถœ๋ ฅ : 8 ์ŠคํŽ˜์ด๋“œ

2) FileOutputView :

System.out.printf("์นด๋“œ ๋žญํฌ : %s, ์นด๋“œ ๋ชจ์–‘ : %s",card.getCardRank().getName(), card.getCardShape().getName());

์ถœ๋ ฅ : ์นด๋“œ ๋žญํฌ : ์ŠคํŽ˜์ด๋“œ, ์นด๋“œ ๋ชจ์–‘ : 8


์‹ค์ œ๋กœ ์ถœ๋ ฅ ํ˜•์‹์— ๋งž์ถ”์–ด ์กฐํ•ฉํ•˜๋Š” ์ฑ…์ž„์„ ์ฃผ๋””๋Š” ์–ด๋””์— ๋‘์‹œ๋Š”์ง€ ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค! ๐Ÿ™‹๐Ÿปโ€โ™€๏ธ

Choose a reason for hiding this comment

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

๋ง์”€ํ•ด์ฃผ์‹  ๊ฒƒ์ฒ˜๋Ÿผ ์ถœ๋ ฅ์€ ์š”๊ตฌ์‚ฌํ•ญ์— ๋”ฐ๋ผ ์ž์ฃผ ๋ณ€๊ฒฝ๋  ์ˆ˜ ์žˆ๋Š” ๋ถ€๋ถ„์ด๋ผ๋ฉด, ์ถœ๋ ฅ ํ˜•์‹์— ๋Œ€ํ•œ ์ฑ…์ž„์„ View์—์„œ ๋‹ด๋‹นํ•˜๋„๋ก ๋‘๋Š” ๋ฐฉํ–ฅ์—๋Š” ๊ณต๊ฐ๊ฐ€๋„ค์š”! ๐Ÿ‘

๋‹ค๋งŒ, ๋””๋ฏธํ„ฐ์˜ ๋ฒ•์น™ ๊ด€์ ์—์„œ๋Š” card.getCardRank().getName()์ฒ˜๋Ÿผ ๊ฐ์ฒด๋ฅผ ์—ฌ๋Ÿฌ ๋ฒˆ ํƒ์ƒ‰ํ•˜๋Š” ๊ตฌ์กฐ๋Š” ์ง€์–‘ํ•˜๋Š” ๊ฒƒ์ด ์ข‹๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.
์ด๋Ÿฐ ๊ตฌ์กฐ๋Š” ๋‚ด๋ถ€ ๊ตฌํ˜„์— ๋Œ€ํ•œ ์˜์กด๋„๊ฐ€ ๋†’์•„์ ธ์„œ, ์˜ˆ๋ฅผ ๋“ค์–ด Card ๋‚ด๋ถ€ ๊ตฌ์กฐ๊ฐ€ ๋ณ€๊ฒฝ๋˜๋ฉด (CardRank๊ฐ€ ์‚ฌ๋ผ์ง€๊ฑฐ๋‚˜ ๊ตฌ์กฐ๊ฐ€ ๋ฐ”๋€Œ๋Š” ๋“ฑ) ์ด๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ชจ๋“  ์ฝ”๋“œ๊ฐ€ ํ•จ๊ป˜ ์˜ํ–ฅ์„ ๋ฐ›๊ฒŒ ๋˜๋Š” ๋ฌธ์ œ๊ฐ€ ์žˆ๊ฒ ์ง€์š”!
๋˜ํ•œ ๊ฐ์ฒด์—๊ฒŒ ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ด๊ธฐ๋ณด๋‹ค๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ๊บผ๋‚ด ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ์‹์ด ๋˜์–ด, ๊ฐ์ฒด์ง€ํ–ฅ์ ์ธ ์ฑ…์ž„ ๋ถ„๋ฆฌ๊ฐ€ ํ๋ ค์งˆ ์ˆ˜ ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.
๊ทธ๋ž˜์„œ ๊ฐ€๋Šฅํ•˜๋‹ค๋ฉด Card๊ฐ€ ์Šค์Šค๋กœ ํ•„์š”ํ•œ ๊ฐ’์„ ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ๋Š” ๋ฉ”์‹œ์ง€๋ฅผ ์ œ๊ณตํ•ด์ฃผ๋Š” ๋ฐฉํ–ฅ๋„ ๊ณ ๋ คํ•ด๋ณผ ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™์•„์š”~!

@ParkJiYeoung8297
Copy link
Author

ParkJiYeoung8297 commented Mar 16, 2026

์ฃผ๋””. ์ฝ”๋“œ ๋ฆฌ๋ทฐ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. โ˜บ๏ธ
ํ”ผ๋“œ๋ฐฑ ์ฃผ์‹  ๊ฒƒ์„ ๋ฐ”ํƒ•์œผ๋กœ ์•„๋ž˜์˜ ์‚ฌํ•ญ๋“ค์„ ์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค!

์‚ฌ์ดํด 2์˜ ์ˆ˜์ •์‚ฌํ•ญ (260316)

  • ๋‹จ์ผ ๋ฐ˜ํ™˜ ๋žŒ๋‹ค์‹์—์„œ ์ค‘๊ด„ํ˜ธ ๋ฐ return ์ œ๊ฑฐ
  • OutputView์—์„œ ๋„๋ฉ”์ธ ์ •์ฑ… ์ œ๊ฑฐ (๋ฆฌ๋ทฐ์–ด ํ™•์ธ ํ•„์š”!)
  • Card์—์„œ Ace ํŒ๋‹จ ์—ฌ๋ถ€ ๋ฉ”์„œ๋“œ ์ˆ˜์ •(์บก์Аํ™”) - get ํ•˜์ง€ ์•Š๊ณ , isAce๋กœ boolean์„ return
  • ๊ธฐ๋Šฅ ์ฑ…์ž… ๋ถ„๋ฆฌ (๊ฒŒ์ž„ ํŒ๋‹จ ์ฑ…์ž„, ๋ˆ ๊ณ„์‚ฐ ์ฑ…์ž„)
  • ํ…Œ์ŠคํŠธ๋งŒ์„ ์œ„ํ•œ ๋ฉ”์„œ๋“œ ์‚ญ์ œ
  • ํ…Œ์ŠคํŠธ ์œ ํ‹ธ์„ ์ด์šฉํ•ด ์ค‘๋ณต ์ œ๊ฑฐ (for ์œ ์—ฐํ•œ ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•จ)

Copy link

@jurlring jurlring left a comment

Choose a reason for hiding this comment

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

์•„ํ‹ฐ ์•ˆ๋…•ํ•˜์„ธ์š”!
๋ฌธ์˜์— ๋Œ€ํ•œ ๋‹ต๋ณ€๊ณผ ์ฝ”๋ฉ˜ํŠธ ๋ช‡๊ฐ€์ง€ ๋‚จ๊ฒจ๋‘์—ˆ์–ด์š” :)
์‹œ๊ฐ„ ๊ดœ์ฐฎ์œผ์‹ค ๋•Œ ํ™•์ธํ•ด์ฃผ์„ธ์š”!

public List<Card> getCards() {
return cards;
}
}

Choose a reason for hiding this comment

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

๋ถˆ๋ณ€ ์ปฌ๋ ‰์…˜์— ๋Œ€ํ•ด์„œ ํ•™์Šตํ•ด๋ณด๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”!
https://tecoble.techcourse.co.kr/post/2021-04-26-defensive-copy-vs-unmodifiable/

Comment on lines +63 to +64
public void betMoney(int money) {
bettingScore = money;

Choose a reason for hiding this comment

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

betting score๋Š” ํ”Œ๋ ˆ์ด์–ดํ•œํ…Œ ์ค‘์š”ํ•œ ๊ฐ’์ธ๋ฐ, betMoney๋กœ ์™ธ๋ถ€์— ์ˆ˜์ •์ด ๊ฐ€๋Šฅํ•œ ๋ฉ”์„ธ์ง€๋ฅผ ๋…ธ์ถœํ•˜๊ณ  ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ์–ด์š”.

controller์—์„œ List names๋ฅผ ๋Œ๋ ค์„œ betting score๋ฅผ ๋ฐ›์œผ๋ฉด ์–ด๋–ค ๋ฌธ์ œ๊ฐ€ ์žˆ์–ด์š”?

import domain.dto.MatchResultDto;
import domain.enums.MatchCase;

public final class OutputView {

Choose a reason for hiding this comment

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

๋„ค ์ˆ˜์ •ํ•ด์ฃผ์‹  ๋ถ€๋ถ„์ด ๋งž์Šต๋‹ˆ๋‹ค~! ๋„๋ฉ”์ธ ์ •์ฑ…์— ๋Œ€ํ•œ ๊ตฌํ˜„์ด view์— ์žˆ์œผ๋ฉด ๋„๋ฉ”์ธ ์ •์ฑ…์ด ์‘์ง‘๋˜์–ด ์žˆ์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— view๊ฐ€ ๋ฐ”๋€” ๋•Œ๋งˆ๋‹ค ๊ณ ๋ คํ•ด์•ผํ•˜๊ณ , ๋†“์น˜๊ฒŒ๋˜๋ฉด ์žฅ์• ๋กœ ์ด๋ฃจ์–ด์ง€๊ฒ ์ฃ  ๐Ÿ˜ฑ ๊ทธ๋ ‡๋‹ค๋ฉด MVC๊ตฌ์กฐ๋กœ ์„ค๊ณ„ํ•˜์‹  ์˜๋ฏธ๋„ ์—†๊ตฌ์š”!

enum์€ ์ƒ์ˆ˜์˜ ์ง‘ํ•ฉ์ด๊ธฐ ๋•Œ๋ฌธ์— ๊ฐ’์„ ์ง์ ‘ getํ•˜๋Š” ๊ฒƒ์€ ๊ดœ์ฐฎ๋‹ค๋ผ๊ณ  ์ƒ๊ฐํ•˜์…จ๊ตฐ์š”~!
์ข‹์€ ์ ‘๊ทผ์ด์ง€๋งŒ displayCardContent์—์„œ card.getCardRank().getName() + card.getCardShape().getName() ์ด๋ ‡๊ฒŒ Card์˜ ๋‚ด๋ถ€ ๊ตฌ์กฐ๋ฅผ OutputView๊ฐ€ ์ง์ ‘ ์กฐํ•ฉํ•˜๊ณ  ์žˆ์–ด์š”! ๋งŒ์•ฝ ์นด๋“œ ํ‘œํ˜„ ๋ฐฉ์‹์ด ๋ฐ”๋€Œ๋ฉด OutputView๋ฅผ ์ˆ˜์ •ํ•ด์•ผ ํ•˜๋Š”๋ฐ, ์ด๊ฑด View์˜ ์ฑ…์ž„์ผ๊นŒ์š”?!

Comment on lines +28 to 53
public MatchCase calculateMatchCase(int dealerTotal) {
if (cards.getFinalScore() > dealerTotal) {
return MatchCase.WIN;
}
if (cards.getFinalScore() == dealerTotal) {
return MatchCase.DRAW;
}
if (cards.getFinalScore() < dealerTotal) {
return MatchCase.LOSE;
}
throw new IllegalArgumentException("[ERROR] ์ผ์น˜ํ•˜๋Š” enum์ด ์—†์Šต๋‹ˆ๋‹ค.");
}

private int calculateAceScore() {
if (!isAceExist() || calculateScore() > 11) {
return ACE_ADDITION_NONE_SCORE;
public void calculateMoney(MatchCase matchCase, boolean isDealerBlackjack) {
if (cards.isBlackjack() && !isDealerBlackjack) {
bettingScore = (int) ((int) bettingScore * Game.BLACKJACK_BONUS);
return;
}
if (matchCase.equals(MatchCase.LOSE)) {
loseMoney();
return;
}

if (matchCase.equals(MatchCase.WIN)) {
return;
}

Choose a reason for hiding this comment

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

๋ฉ”์„œ๋“œ๋ฅผ ๋ถ„๋ฆฌํ•œ ๊ฒƒ๊ณผ ์ฑ…์ž„์ด ๋ถ„๋ฆฌ๋˜์—ˆ๋‹ค๋Š” ๋‹ค๋ฅธ ๊ฒƒ ๊ฐ™์•„์š”!
๋ง์”€์ฃผ์‹ ๋Œ€๋กœ๋ผ๋ฉด ์Šน๋ถ€ ํŒ๋‹จ ์ฑ…์ž„์€ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๊ฐ€์ง€๋Š”๋ฐ, ๊ธฐ์กด์—๋„ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๊ฐ€์ง„ ์ฑ…์ž„์ด ์žˆ์ง€์š”..! ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์นด๋“œ๋„ ๋“ค๊ณ ์žˆ๊ณ , ๋ฒ ํŒ…๊ธˆ์•ก๋„ ๋“ค๊ณ  ์žˆ๊ณ , ์ŠนํŒจ๋„ ํŒ๋‹จํ•˜๋Š”๋ฐ ๋‹จ์ผ ์ฑ…์ž„์›์น™์„ ์ง€์ผฐ๋‹ค๊ณ  ๋ณผ ์ˆ˜ ์žˆ์„๊นŒ์š”?!
์นด๋“œ๋ฅผ ๊ฐ€์ง„ ์ฐธ๊ฐ€์ž์™€ ๋ฒ ํŒ…์„ ํ•˜๋Š” ์ฐธ๊ฐ€์ž๋ฅผ ๋‚˜๋ˆ„๋ฉด ์–ด๋•Œ์š”?

@ParkJiYeoung8297
Copy link
Author

์‚ฌ์ดํด 2์˜ ์ˆ˜์ •์‚ฌํ•ญ2 (260318)

  • allMatch์— ๋นˆ ๋ฆฌ์ŠคํŠธ๊ฐ€ ํ•ญ์ƒ true๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ๋ฌธ์ œ ์ˆ˜์ • (Players)
  • ๋ฉ”์„œ๋“œ์—์„œ ์‚ฌ์šฉ์•ˆํ•˜๋Š” ํŒŒ๋ผ๋ฏธํ„ฐ ์ œ๊ฑฐ (Game)
  • ์ž๋ฐ” ๋„ค์ด๋ฐ ์ปจ๋ฒค์…˜ - ์นด๋ฉœ ์ผ€์ด์Šค ์ ์šฉ (OutputView)
  • ์™ธ๋ถ€์—์„œ betMoney๋กœ ๊ฐ’ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ๋Š” ๋ฌธ์ œ ์ˆ˜์ • (Player)
  • ๋ฐฐํŒ… ์ ์ˆ˜ ๊ณ„์‚ฐ ์ฑ…์ž„ ๋ถ„๋ฆฌ๋ฅผ ์œ„ํ•ด Betting ๋„๋ฉ”์ธ ์ƒ์„ฑ(Player์˜ ์ฑ…์ž„ ๋ถ„๋ฆฌ)
  • ๋ถˆ๋ณ€ ์ปฌ๋ ‰์…˜ ๋ฐฉ์–ด์  ๋ณต์‚ฌ ์ ์šฉ
  • ๋ž˜ํผ ํƒ€์ž…์—์„œ ๋ถˆํ•„์š”ํ•˜๊ฒŒ ์›์‹œ๊ฐ’์œผ๋กœ ๋ณ€๊ฒฝํ•˜๋Š” ๋ฌธ์ œ ์ˆ˜์ • (OutputView)
  • Dealer ๋„๋ฉ”์ธ ์ƒ์„ฑ ๋ฐ ์ฑ…์ž„ ๋ถ„๋ฆฌ

Player์˜ ์ฑ…์ž„์„ ์ค„์ด๊ธฐ ์œ„ํ•ด Betting๊ณผ Dealer ๋„๋ฉ”์ธ์„ ์ƒ์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค.
๋ˆ ๊ณ„์‚ฐ์— ๋Œ€ํ•œ ์ฑ…์ž„์„ Betting์—๊ฒŒ, ๋”œ๋Ÿฌ์— ๋Œ€ํ•œ ์ฑ…์ž„์„ Dealer์—๊ฒŒ ๋ถ€์—ฌํ•ด, ์ฑ…์ž„์„ ๋ถ„๋ฆฌํ–ˆ์Šต๋‹ˆ๋‹ค.

Copy link

@jurlring jurlring left a comment

Choose a reason for hiding this comment

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

์•„ํ‹ฐ ์•ˆ๋…•ํ•˜์„ธ์š”!
์ฝ”๋ฉ˜ํŠธ ๋ช‡๊ฐ€์ง€ ๋‚จ๊ฒผ๋Š”๋ฐ ์‹œ๊ฐ„ ๊ดœ์ฐฎ์œผ์‹ค ๋•Œ ํ™•์ธ๋ถ€ํƒ๋“œ๋ ค์š” :)

cards.addCard(card);
}

public void addInitializedCard(Deck deck) {

Choose a reason for hiding this comment

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

๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด์˜ ํ–‰์œ„๋“ค์ด ๋„ˆ๋ฌด ๋งŽ์ด ์ค‘๋ณต๋˜๋Š” ๊ฒƒ ๊ฐ™์•„์š”! ์ค‘๋ณต ์ฝ”๋“œ๋ฅผ ์—†์• ๋Š”๊ฑด ์–ด๋–จ๊นŒ์š”?

return cards.getFinalScore() > Game.BLACKJACK_VALUE;
}

public boolean isDealerBlackjack() {

Choose a reason for hiding this comment

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

๋”œ๋Ÿฌ ๊ฐ์ฒด๊ฐ€ isDealerBlackjack์ด๋ผ๋Š” ํ–‰์œ„๋ฅผ ํ•˜๋Š”๊ฑด ์ค‘๋ณต์ผ ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™์•„์š”!
dealer.isDealerBlackjack ๋”œ๋Ÿฌ๊ฐ€ ๋‘๋ฒˆ ๋“ค์–ด๊ฐ€๋Š”๋ฐ ํ•„์š”ํ• ๊นŒ์š”?!

Comment on lines +28 to 53
public MatchCase calculateMatchCase(int dealerTotal) {
if (cards.getFinalScore() > dealerTotal) {
return MatchCase.WIN;
}
if (cards.getFinalScore() == dealerTotal) {
return MatchCase.DRAW;
}
if (cards.getFinalScore() < dealerTotal) {
return MatchCase.LOSE;
}
throw new IllegalArgumentException("[ERROR] ์ผ์น˜ํ•˜๋Š” enum์ด ์—†์Šต๋‹ˆ๋‹ค.");
}

private int calculateAceScore() {
if (!isAceExist() || calculateScore() > 11) {
return ACE_ADDITION_NONE_SCORE;
public void calculateMoney(MatchCase matchCase, boolean isDealerBlackjack) {
if (cards.isBlackjack() && !isDealerBlackjack) {
bettingScore = (int) ((int) bettingScore * Game.BLACKJACK_BONUS);
return;
}
if (matchCase.equals(MatchCase.LOSE)) {
loseMoney();
return;
}

if (matchCase.equals(MatchCase.WIN)) {
return;
}

Choose a reason for hiding this comment

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

๋‹จ์ผ ์ฑ…์ž„ ์›์น™์€ ๋กœ๋ฒ„ํŠธ ๋งˆํ‹ด(Robert C. Martin)์ด ์ œ์•ˆํ•œ SOLID ์›์น™์ค‘์— ํ•˜๋‚˜๋กœ ๊ฐ์ฒด ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ๋ฐ ์„ค๊ณ„์—์„œ ์œ ์ง€๋ณด์ˆ˜๊ฐ€ ์‰ฝ๊ณ , ํ™•์žฅ ๊ฐ€๋Šฅํ•˜๋ฉฐ, ๊ฒฌ๊ณ ํ•œ ์ฝ”๋“œ๋ฅผ ๋งŒ๋“ค๊ธฐ ์œ„ํ•œ 5๊ฐ€์ง€ ํ•ต์‹ฌ ์›์น™์ค‘ ํ•˜๋‚˜์ธ๋ฐ์š”!
๊ทธ๋ ‡๋‹ค๋ณด๋‹ˆ ๋ฉ”์„œ๋“œ ๋‹จ์œ„๊ฐ€ ์•„๋‹ˆ๋ผ ๊ฐ์ฒด ๋‹จ์œ„๋กœ ์ง€์ผœ์•ผํ•ฉ๋‹ˆ๋‹ค.
์ง€๊ธˆ ๋‚˜๋ˆ ์ฃผ์‹ ๊ฑด Betting์˜ ์›์‹œ๊ฐ’์„ ํฌ์žฅํ•ด์ฃผ์‹  ๊ฒƒ ๊ฐ™๊ณ , ์•„์ง ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์นด๋“œ๋„ ๋“ค๊ณ ์žˆ๊ณ , ๋ฒ ํŒ…๊ธˆ์•ก์„ ๊ณ„์‚ฐํ•˜๊ณ , ์ŠนํŒจ๋„ ํŒ๋‹จํ•˜๊ณ  ์žˆ๋Š” ๊ฒƒ์œผ๋กœ ๋ณด์ด๋Š”๋ฐ์š”.
์ŠนํŒจ๋ฅผ MatchCase๊ฐ€ ํŒ๋‹จํ•˜๋ฉด ์•ˆ๋˜๋‚˜์š”?
๋ฒ ํŒ…๊ธˆ์•ก์„ ๊ณ„์‚ฐ์„ ๊ผญ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ํ•ด์•ผํ• ๊นŒ์š”?

๋‹จ์ผ ์ฑ…์ž„ ์›์น™์„ ์ ์šฉํ•˜๊ธฐ ์ „์— ๋‹จ์ผ ์ฑ…์ž„ ์›์น™์ด ๋ญ”์ง€ ๋‹จ์ผ ์ฑ…์ž„ ์›์น™์„ ์ง€ํ‚ค๋ฉด ์–ด๋–ค ์žฅ์ ์ด ์žˆ์„์ง€ ๊ณ ๋ฏผํ•ด๋ณด์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค! :)

import domain.dto.MatchResultDto;
import domain.enums.MatchCase;

public final class OutputView {

Choose a reason for hiding this comment

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

๋ง์”€ํ•ด์ฃผ์‹  ๊ฒƒ์ฒ˜๋Ÿผ ์ถœ๋ ฅ์€ ์š”๊ตฌ์‚ฌํ•ญ์— ๋”ฐ๋ผ ์ž์ฃผ ๋ณ€๊ฒฝ๋  ์ˆ˜ ์žˆ๋Š” ๋ถ€๋ถ„์ด๋ผ๋ฉด, ์ถœ๋ ฅ ํ˜•์‹์— ๋Œ€ํ•œ ์ฑ…์ž„์„ View์—์„œ ๋‹ด๋‹นํ•˜๋„๋ก ๋‘๋Š” ๋ฐฉํ–ฅ์—๋Š” ๊ณต๊ฐ๊ฐ€๋„ค์š”! ๐Ÿ‘

๋‹ค๋งŒ, ๋””๋ฏธํ„ฐ์˜ ๋ฒ•์น™ ๊ด€์ ์—์„œ๋Š” card.getCardRank().getName()์ฒ˜๋Ÿผ ๊ฐ์ฒด๋ฅผ ์—ฌ๋Ÿฌ ๋ฒˆ ํƒ์ƒ‰ํ•˜๋Š” ๊ตฌ์กฐ๋Š” ์ง€์–‘ํ•˜๋Š” ๊ฒƒ์ด ์ข‹๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.
์ด๋Ÿฐ ๊ตฌ์กฐ๋Š” ๋‚ด๋ถ€ ๊ตฌํ˜„์— ๋Œ€ํ•œ ์˜์กด๋„๊ฐ€ ๋†’์•„์ ธ์„œ, ์˜ˆ๋ฅผ ๋“ค์–ด Card ๋‚ด๋ถ€ ๊ตฌ์กฐ๊ฐ€ ๋ณ€๊ฒฝ๋˜๋ฉด (CardRank๊ฐ€ ์‚ฌ๋ผ์ง€๊ฑฐ๋‚˜ ๊ตฌ์กฐ๊ฐ€ ๋ฐ”๋€Œ๋Š” ๋“ฑ) ์ด๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ชจ๋“  ์ฝ”๋“œ๊ฐ€ ํ•จ๊ป˜ ์˜ํ–ฅ์„ ๋ฐ›๊ฒŒ ๋˜๋Š” ๋ฌธ์ œ๊ฐ€ ์žˆ๊ฒ ์ง€์š”!
๋˜ํ•œ ๊ฐ์ฒด์—๊ฒŒ ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ด๊ธฐ๋ณด๋‹ค๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ๊บผ๋‚ด ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ์‹์ด ๋˜์–ด, ๊ฐ์ฒด์ง€ํ–ฅ์ ์ธ ์ฑ…์ž„ ๋ถ„๋ฆฌ๊ฐ€ ํ๋ ค์งˆ ์ˆ˜ ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.
๊ทธ๋ž˜์„œ ๊ฐ€๋Šฅํ•˜๋‹ค๋ฉด Card๊ฐ€ ์Šค์Šค๋กœ ํ•„์š”ํ•œ ๊ฐ’์„ ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ๋Š” ๋ฉ”์‹œ์ง€๋ฅผ ์ œ๊ณตํ•ด์ฃผ๋Š” ๋ฐฉํ–ฅ๋„ ๊ณ ๋ คํ•ด๋ณผ ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™์•„์š”~!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants