Skip to content

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

Open
yj9107v wants to merge 82 commits intowoowacourse:yj9107vfrom
yj9107v:yj9107v

Conversation

@yj9107v
Copy link

@yj9107v yj9107v commented Mar 7, 2026

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

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

์–ด๋–ค ๋ถ€๋ถ„์— ์ง‘์ค‘ํ•˜์—ฌ ๋ฆฌ๋ทฐํ•ด์•ผ ํ• ๊นŒ์š”?

  • ํ…Œ์ŠคํŠธ ๋‹จ์œ„์— ๋Œ€ํ•œ ๋ช…ํ™•ํ•œ ๊ธฐ์ค€
  • TDD์˜ ๊ตฌํ˜„ ์„ค๊ณ„

1๏ธโƒฃ ์˜ฌ๋ฐ”๋ฅธ TDD ๊ตฌํ˜„์ด๋ž€?

์ œ๊ฐ€ ์ƒ๊ฐํ•œ TDD๋Š” ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•˜๊ธฐ ์ „์— ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋ฅผ ๋จผ์ € ์ž‘์„ฑํ•ด ์•ˆ์ •์„ฑ์„ ๋†’์ด๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋˜ํ•œ Redโ€“Greenโ€“Blue ๋‹จ๊ณ„๋กœ, ํ…Œ์ŠคํŠธ๊ฐ€ ์‹คํŒจํ•˜๋Š” ์ฝ”๋“œ๋ฅผ ๋จผ์ € ๋งŒ๋“  ๋’ค โ†’ ํ…Œ์ŠคํŠธ๋ฅผ ํ†ต๊ณผํ•˜๋„๋ก ๊ตฌํ˜„ํ•˜๊ณ (ํ…Œ์ŠคํŠธ ์ฝ”๋“œ์—์„œ ๊ตฌํ˜„ํ•จ) โ†’ ๋ฆฌํŒฉํ† ๋งํ•œ ํ›„(ํ…Œ์ŠคํŠธ ์ฝ”๋“œ์—์„œ ๋ฆฌํŒฉํ† ๋ง) โ†’ ์‹ค์ œ ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•˜๋Š” ํ๋ฆ„์œผ๋กœ ์ดํ•ดํ–ˆ์Šต๋‹ˆ๋‹ค.

์ •๋‹ต์ด ์žˆ๋Š”์ง€๋Š” ๋ชจ๋ฅด๊ฒ ์ง€๋งŒ, ์ด๋Ÿฌํ•œ ๋ฐฉ์‹์ด ์˜ฌ๋ฐ”๋ฅธ TDD ๊ตฌํ˜„์ธ์ง€ ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค.


2๏ธโƒฃ TDD์˜ ์šฐ์„ ์ˆœ์œ„

๊ธฐ๋Šฅ ์š”๊ตฌ ์‚ฌํ•ญ์„ ์ฝ๊ณ , ํ”„๋กœ๊ทธ๋žจ์˜ ํ๋ฆ„์— ๋งž์ถฐ ๊ธฐ๋Šฅ ๋ชฉ๋ก์„ ์ž‘์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค.

์ดํ›„ TDD๋ฅผ ๊ตฌํ˜„ํ•˜๊ธฐ ์œ„ํ•ด ๊ธฐ์ดˆ ๋„๋ฉ”์ธ ์„ค๊ณ„๊ฐ€ ํ•„์š”ํ•˜๋‹ค๊ณ  ํŒ๋‹จํ•ด ๋ธ”๋ž™์žญ ๋ฑ(Cards)์„ ๋งŒ๋“ค๊ณ  ์‹œ์ž‘ํ–ˆ๊ณ , ์ด ๊ณผ์ •์—์„œ ํ”„๋กœ๊ทธ๋žจ ํ๋ฆ„์— ๋งž์ถฐ TDD๋ฅผ ์ž‘์„ฑํ•˜๊ธฐ๋ณด๋‹ค๋Š” ๋ธ”๋ž™์žญ์˜ ํ•ต์‹ฌ ๊ธฐ๋Šฅ์ธ ์นด๋“œ ํ•ฉ๊ณ„์™€ ACE 1/11 ์ฒ˜๋ฆฌ์— ๋Œ€ํ•œ TDD๋ฅผ ๋จผ์ € ์ž‘์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค.

๊ทธ๋Ÿฐ๋ฐ ์นด๋“œ ํ•ฉ๊ณ„๋ฅผ ํ…Œ์ŠคํŠธํ•˜๊ธฐ ์œ„ํ•ด Player๋ฅผ ๋งŒ๋“ค๊ฒŒ ๋˜์—ˆ๊ณ , Player์— draw() ๊ธฐ๋Šฅ์ด ์ถ”๊ฐ€๋˜๋ฉด์„œ TDD๋ฅผ ์ž‘์„ฑํ•˜๋ ค๋‹ค ๋ณด๋‹ˆ Player์˜ TDD๋ฅผ ๋†“์น˜๊ฒŒ ๋˜๋Š” ์•…์ˆœํ™˜์ด ๋ฐ˜๋ณต๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

์ฒซ TDD๋ฅผ ๊ตฌํ˜„ํ•˜๋ฉฐ ๋А๋‚€ ์ ์€, ํ”„๋กœ๊ทธ๋žจ์˜ ํ๋ฆ„์— ๋งž์ถฐ TDD๋ฅผ ๊ตฌํ˜„ํ•˜๋Š” ๊ฒƒ์ด ์˜ฌ๋ฐ”๋ฅธ ์šฐ์„ ์ˆœ์œ„๊ฐ€ ๋  ์ˆ˜ ์žˆ๊ฒ ๋‹ค๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ œ ์˜๊ฒฌ์— ๋Œ€ํ•ด ์–ด๋–ป๊ฒŒ ์ƒ๊ฐํ•˜์‹œ๋Š”์ง€ ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค!


3๏ธโƒฃ ํ…Œ์ŠคํŠธ ๋‹จ์œ„

์ด๋ฒˆ ํŽ˜์–ด ํ”„๋กœ๊ทธ๋ž˜๋ฐ์—์„œ ๊ฐ€์žฅ ๊ณ ๋ฏผํ–ˆ๊ณ  ์–ด๋ ค์› ๋˜ ๋ถ€๋ถ„์€ ํ…Œ์ŠคํŠธ ๋‹จ์œ„์˜€์Šต๋‹ˆ๋‹ค.

ํ…Œ์ŠคํŠธ ๋‹จ์œ„ ๊ทœ์น™ ์ค‘ ํ•˜๋‚˜๋กœ โ€œ๋น„์ฆˆ๋‹ˆ์Šค ๊ทœ์น™์ด ๋“ค์–ด๊ฐ„ ๋ฉ”์„œ๋“œ ๋‹จ์œ„๋กœ ํ…Œ์ŠคํŠธํ•œ๋‹คโ€๋ฅผ ์ •ํ–ˆ์ง€๋งŒ, ๊ทธ๋Ÿผ์—๋„ ํ˜ผ๋ž€์ด ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

์˜ˆ๋ฅผ ๋“ค์–ด ๋น„์ฆˆ๋‹ˆ์Šค ์ถœ๋ ฅ์„ ์œ„ํ•ด ํ”Œ๋ ˆ์ด์–ด ์ด๋ฆ„์ด๋‚˜ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๋ณด์œ ํ•œ ์นด๋“œ๋“ค์„ ์ €์žฅํ•œ List ๋ฐ˜ํ™˜๊ฐ’์„ ํ…Œ์ŠคํŠธํ•ด์•ผ ํ•˜๋Š”์ง€, ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์นด๋“œ 2์žฅ์„ draw() ํ–ˆ์„ ๋•Œ ์นด๋“œ๋ฅผ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ๋ฐ›์•˜๋Š”์ง€๋„ ํ…Œ์ŠคํŠธํ•ด์•ผ ํ•˜๋Š”์ง€ ๋“ฑ ํ•˜๋‚˜ํ•˜๋‚˜ ์˜๋ฌธ์ด ์ƒ๊ธฐ๋‹ค ๋ณด๋‹ˆ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๋Š” ๊ณผ์ •์ด ๋งค์šฐ ํ˜ผ๋ž€์Šค๋Ÿฌ์› ์Šต๋‹ˆ๋‹ค.

ํ…Œ์ŠคํŠธ๋ฅผ ํ•ด์•ผ ํ•˜๋Š” ๋ช…ํ™•ํ•œ ๊ธฐ์ค€์ด ์žˆ์„๊นŒ์š”? ํ…Œ์ŠคํŠธ ์ œ์™ธ ๊ทœ์น™์€ ์ž…์ถœ๋ ฅ ๊ด€๋ จ ๋ฉ”์„œ๋“œ๋กœ ์ •ํ–ˆ๋Š”๋ฐ, ์ด๋Ÿฐ ๊ทœ์น™๋“ค์ด ํ˜ผํ•ฉ๋˜๋ฉด์„œ ์˜คํžˆ๋ ค ๋ฌด์—‡์„ ํ…Œ์ŠคํŠธํ•ด์•ผ ํ•˜๋Š”์ง€ ๋” ํ—ท๊ฐˆ๋ฆฌ๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๋ฆฌ๋ทฐ์–ด๋‹˜์˜ ํ…Œ์ŠคํŠธ ๊ธฐ์ค€์ด ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค!


yj9107v added 30 commits March 5, 2026 10:48
InputParser ํด๋ž˜์Šค ์ถ”๊ฐ€

๊ตฌ๋ถ„์ž(',') ๊ธฐ์ค€ ์ž…๋ ฅ ๊ฐ’ ๋ถ„๋ฆฌ ๊ธฐ๋Šฅ ๊ตฌํ˜„
- ์‚ฌ์šฉ์ž ์ด๋ฆ„ ์ž…๋ ฅ ๊ฐ’์ด ๊ณต๋ฐฑ์ธ ๊ฒฝ์šฐ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ ํ…Œ์ŠคํŠธ
- ์‚ฌ์šฉ์ž ์ด๋ฆ„ ์ž…๋ ฅ ๊ฐ’์ด ๊ณต๋ฐฑ์ธ ๊ฒฝ์šฐ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ
- Suit: ์นด๋“œ์˜ ๋ชจ์–‘์„ ์ •์˜
- Rank: ์นด๋“œ์˜ ์ˆซ์ž๋ฅผ ์ •์˜
- ์ •์  ํŒฉํ† ๋ฆฌ ๋ฉ”์„œ๋“œ ์ƒ์„ฑ
- ์นด๋“œ์˜ ์ •๋ณด๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ๋ฉ”์„œ๋“œ getName() ์ƒ์„ฑ
- ์ •์  ํŒฉํ† ๋ฆฌ ๋ฉ”์„œ๋“œ ์ƒ์„ฑ
- ์นด๋“œ ๋ฑ์„ ์ƒ์„ฑํ•˜๋Š” ๋ฉ”์„œ๋“œ generateCards() ์ƒ์„ฑ
- ์ •์  ํŒฉํ† ๋ฆฌ ๋ฉ”์„œ๋“œ ์ƒ์„ฑ
- ์นด๋“œ๋ฅผ ์ถ”๊ฐ€ํ•˜๋Š” ๋ฉ”์„œ๋“œ addCard() ์ƒ์„ฑ
- player ์ ์ˆ˜ ํ•ฉ๊ณ„๋ฅผ ๊ณ„์‚ฐํ•˜๋Š” ๋ฉ”์„œ๋“œ calculateScore() ์ƒ์„ฑ
- ํ”Œ๋ ˆ์ด์–ด ์ ์ˆ˜ ํ•ฉ๊ณ„๊ฐ€ 21์ดˆ๊ณผ ์‹œ ACE ํฌํ•จํ•œ ๊ฒฝ์šฐ ์ ์ˆ˜ ๋ณด์ • ํ…Œ์ŠคํŠธ
- ํ”Œ๋ ˆ์ด์–ด ์ ์ˆ˜ ํ•ฉ๊ณ„๊ฐ€ 21์ดˆ๊ณผ ์‹œ ACE ํฌํ•จํ•œ ๊ฒฝ์šฐ ์ ์ˆ˜ ๋ณด์ • ๋ฉ”์„œ๋“œ isBustWithAce()
- 2์žฅ ๋“œ๋กœ์šฐ drawInitialHand() ์ถ”๊ฐ€
- 1์žฅ ๋“œ๋กœ์šฐ draw() ์ถ”๊ฐ€
- ์นด๋“œ ๋ฐฐ๋ถ„ ๊ธฐ๋Šฅ ์ถ”๊ฐ€
- ์ •์  ํŒฉํ† ๋ฆฌ ๋ฉ”์„œ๋“œ
- ์ ์ˆ˜ ๊ณ„์‚ฐ ๋ฉ”์„œ๋“œ calculateScore()
- ace ํŒ์ • ์ „ ์ ์ˆ˜ ๊ณ„์‚ฐ ๋ฉ”์„œ๋“œ calculateRawScore()
- ace ๊ด€๋ จ ๋ฉ”์„œ๋“œ countAce(), adjustForAce(), isBustWithAce()
- ๋”œ๋Ÿฌ ์นด๋“œ ์ •๋ณด ๋ฐ˜ํ™˜ ๋ฉ”์„œ๋“œ getDealerInfo(), getDealerInitialInfo()
- name ํ•„๋“œ ์ถ”๊ฐ€
- ์ ์ˆ˜ ๊ณ„์‚ฐ ๋กœ์ง calculateScore() ์ˆ˜์ •
- ์ •๋ณด ๋ฐ˜ํ™˜ ๋ฉ”์„œ๋“œ getPlayerInfo(), getCardsInfo()
- ํ”Œ๋ ˆ์ด์–ด๋“ค์˜ ์ •๋ณด ๋ฐ˜ํ™˜ ๋ฉ”์„œ๋“œ getUserNames(), getPlayerInfo()
- ์‚ฌ์šฉ์ž๋“ค์—๊ฒŒ ์นด๋“œ ์ถ”๊ฐ€ ์—ฌ๋ถ€ ๊ธฐ๋Šฅ ์™„์„ฑ
- ํ”Œ๋ ˆ์ด์–ด์˜ ์นด๋“œ๊ฐ€ 1์žฅ์ด ์ถ”๊ฐ€๋˜์–ด ์ด 3์žฅ์ด ๋˜์—ˆ๋Š”์ง€
yj9107v added 9 commits March 9, 2026 09:25
- list์˜ size()๋ฅผ ์ง์ ‘ ํ˜ธ์ถœํ•˜์ง€ ์•Š๊ณ , ํฌ๊ธฐ๋ฅผ ๋น„๊ตํ•  ์ˆ˜ ์žˆ๊ฒŒ ์ˆ˜์ •
- ์ฝ”๋“œ ์ž‘์„ฑ ์œ„์น˜ ํ•ด๊ฒฐ (ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋Š” Red, Green blue๋Š” ํ”„๋กœ๋•์…˜ ์ฝ”๋“œ
- list์˜ size()๋ฅผ ์ง์ ‘ ํ˜ธ์ถœํ•˜์ง€ ์•Š๊ณ , ํฌ๊ธฐ๋ฅผ ๋น„๊ตํ•  ์ˆ˜ ์žˆ๊ฒŒ ์ˆ˜์ •, isEqualTo() -> hasSize() ์ˆ˜์ •
- ๋”œ๋Ÿฌ ์นด๋“œ ์ถ”๊ฐ€ ์กฐ๊ฑด๋ฌธ์„ Controller์—์„œ ๋„๋ฉ”์ธ์œผ๋กœ ์˜ฎ๊น€
- ํ”Œ๋ ˆ์ด์–ด ํ•ฉ๊ณ„ 21 ์ดˆ๊ณผ ์—ฌ๋ถ€
- ํ”Œ๋ ˆ์ด์˜ ๋ณด์œ ํ•œ ์นด๋“œ ์ข…๋ฅ˜๊ฐ€ ์˜ฌ๋ฐ”๋ฅธ์ง€ ํ…Œ์ŠคํŠธ
- ํ”Œ๋ ˆ์ด์–ด ์ ์ˆ˜๊ฐ€ 21 ์ดˆ๊ณผ์ธ ๊ฒฝ์šฐ ์ ์ˆ˜ ์ฒ˜๋ฆฌ ํ…Œ์ŠคํŠธ
- ์ถœ๋ ฅ format์€ Controller ๋‹จ์—์„œ ์ฑ…์ž„์ง€๊ฒŒ ์ฝ”๋“œ ์ˆ˜์ •
Copy link

@verus-j verus-j 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 +3 to +10
public class Policy {

public static final int FIRST_DRAW_SIZE = 2;
public static final int DEALER_HIT_THRESHOLD = 16;
public static final int BUST_THRESHOLD = 21;
public static final int ACE_HIGH_LOW_DIFF = 10;
public static final int BUST_SCORE = 0;
}
Copy link

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.

์ „์—ญ ๋ณ€์ˆ˜๋ฅผ ์ง€์ •ํ•˜์…จ๊ตฐ์š”. ๊ฐ์ฒด ์ง€ํ–ฅ์ ์ธ ์ฝ”๋“œ๋ฅผ ์œ„ํ•ด ๊ฐ ์ „์—ญ ๋ณ€์ˆ˜๋ฅผ ์—ฐ๊ด€๋œ ๊ฐ์ฒด๋กœ ์˜ฎ๊ฒจ์„œ ์ „์—ญ ๋ณ€์ˆ˜๋ฅผ ์ œ๊ฑฐํ•ด๋ณด๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

์—ฐ๊ด€๋œ ๊ฐ์ฒด๋กœ ์˜ฎ๊ฒจ ์ „์—ญ ๋ณ€์ˆ˜๋ฅผ ์ œ๊ฑฐํ•˜๋„๋ก ์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.

๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๋‘˜ ๋‹ค ์‚ฌ์šฉํ•˜๋Š” ๋ณ€์ˆ˜๊ฐ€ ์žˆ์—ˆ๋Š”๋ฐ, ์ด์ „์— ๋ง์”€ํ•ด์ฃผ์‹  Rule of Three๋ฅผ ๋– ์˜ฌ๋ ค ์ค‘๋ณต์ด ๋‘ ๋ฒˆ ์ •๋„์ธ ๊ฒฝ์šฐ๋Š” ๋ณ„๋„๋กœ ์ถ”์ถœํ•˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. ์ด๋Ÿฐ ํŒ๋‹จ์ด ๊ดœ์ฐฎ์„์ง€ ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค.

Copy link

Choose a reason for hiding this comment

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

๋งŒ์•ฝ์— ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๋ณ„๋„๋กœ Bust ์กฐ๊ฑด์ด ๋ณ€๊ฒฝ๋œ๋‹ค๋ฉด ์ง€๊ธˆ์ฒ˜๋Ÿผ ์ค‘๋ณต์„ ์ œ๊ฑฐํ•˜์ง€ ์•Š๋Š”๊ฒŒ ์ข‹๊ฒ ๋„ค์š”. ๋‹ค๋ฅธ ์ผ€์ด์Šค๋กœ ๋”œ๋Ÿฌ์™€ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๊ฐ™์ด Bust ์กฐ๊ฑด์ด ๋ณ€๊ฒฝ๋œ๋‹ค๋ฉด ์ค‘๋ณต๋œ ์ฝ”๋“œ๋กœ ์ธํ•ด ํ•จ๊ป˜ ๊นŒ๋จน์ง€ ์•Š๊ณ  ์ˆ˜์ •์„ ํ•ด์•ผ๊ฒ ๊ตฐ์š”. ๋ธ”๋ž™์žญ ๊ฒŒ์ž„์˜ ๊ทœ์น™์ด ์–ด๋А์ •๋„ ์•ˆ์ •๋œ ๊ฒŒ์ž„์ด ์•„๋‹Œ ๋งค์ฃผ ๊ธฐํš์ž์— ์˜ํ•ด ๋ณ€๊ฒฝ๋œ๋‹ค๋ฉด ์–ด๋А ๋ฐฉํ–ฅ์œผ๋กœ ์ง„ํ–‰๋ ์ง€ ์˜ˆ์ธก์„ ํ•  ์ˆ˜ ์—†์„ ๊ฒƒ ๊ฐ™๋„ค์š”.
2๊ฐ€์ง€ ๋ฐฉํ–ฅ์˜ ๋ณ€๊ฒฝ์ ์„ ๊ณ ๋ คํ–ˆ์„ ๋•Œ ๋‘ ๋ฒˆ ์ •๋„์˜ ์ค‘๋ณต์„ ์œ ์ง€ํ•˜๋Š”๊ฒŒ ์ข‹์„๊นŒ์š”? ์•„๋‹ˆ๋ฉด ์ค‘๋ณต์„ ์ œ๊ฑฐํ•˜๋Š”๊ฒŒ ์ข‹์„๊นŒ์š”? ๊ฐœ์ธ์ ์œผ๋กœ๋Š” ์ด์ •๋„๋ฉด ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋„ ์ถฉ๋ถ„ํ•˜๊ณ  ๊ฐ„๋‹จํ•œ ์ผ€์ด์Šค๋‹ˆ ์ค‘๋ณต์„ ์œ ์ง€ํ•˜๋Š” ๊ฒƒ๋„ ์ข‹์€ ๋ฐฉํ–ฅ์ด๋ผ๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. ํ˜„์žฌ๋Š” ์ค‘๋ณต์œผ๋กœ ์ธํ•œ ๊ด€๋ฆฌ ๋น„์šฉ์„ ์ถฉ๋ถ„ํžˆ ๊ฐ๋‹นํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๋ผ๊ณ  ์ƒ๊ฐํ•ด์š”.
ํŒ๋‹จ์ด ๋ช…ํ™•ํžˆ ์•ˆ ์„ค ๊ฒฝ์šฐ์—๋Š” Rule of Three๋ฅผ ๋– ์˜ฌ๋ฆฌ๋ฉฐ ์ ์šฉํ•˜๋Š” ๊ฒƒ๋„ ์ข‹์ง€๋งŒ, ํ•œ๋ฒˆ์”ฉ์€ Rule of Three๋ฅผ ์ง€์ผœ์•ผํ•˜๋Š” ๊ทผ๊ฑฐ๋ฅผ ์ƒ๊ฐํ•ด๋ณด๋Š” ๊ฒƒ๋„ ์ข‹์€ ํ›ˆ๋ จ์ด ๋  ๊ฒƒ ๊ฐ™์•„์š”~

Comment on lines +39 to +41
List<String> expect = List.of(Rank.TEN.getName() + Suit.DIAMOND.getName(),
Rank.FIVE.getName() + Suit.CLOVER.getName());
assertThat(player.getCardsInfo()).isEqualTo(expect);
Copy link

Choose a reason for hiding this comment

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

๊ฒ€์ฆ๋ฌธ์„ ์‚ดํŽด๋ณด๋‹ˆ ๋ฌธ์ž์—ด๋กœ ๋น„๊ตํ•˜๊ณ  ์žˆ๋„ค์š”. ํ•ด๋‹น ๋ฌธ์ž์—ด์€ ๋ทฐ์— ๊ฐ€๊นŒ์šด ์ •๋ณด์ธ ๊ฒƒ ๊ฐ™์€๋ฐ, Card ๋ฆฌ์ŠคํŠธ ํ˜น์€ Rank, Suit๋กœ ๋น„๊ตํ•˜๋ฉด ์–ด๋–จ๊นŒ์š”?

Copy link
Author

Choose a reason for hiding this comment

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

๊ฒ€์ฆ๋ฌธ์„ ์‚ดํŽด๋ณด๋‹ˆ ๋ฌธ์ž์—ด๋กœ ๋น„๊ตํ•˜๊ณ  ์žˆ๋„ค์š”. ํ•ด๋‹น ๋ฌธ์ž์—ด์€ ๋ทฐ์— ๊ฐ€๊นŒ์šด ์ •๋ณด์ธ ๊ฒƒ ๊ฐ™์€๋ฐ, Card ๋ฆฌ์ŠคํŠธ ํ˜น์€ Rank, Suit๋กœ ๋น„๊ตํ•˜๋ฉด ์–ด๋–จ๊นŒ์š”?

ํ”Œ๋ ˆ์ด์–ด์˜ ํ•„๋“œ ๊ฐ’์„ getter๋กœ ๊บผ๋‚ด๋Š” ๊ฒƒ์„ ์ง€์–‘ํ•˜๋ ค๊ณ  ํ–ˆ๋Š”๋ฐ, ๊ทธ ๊ณผ์ •์—์„œ ๋„๋ฉ”์ธ์— ๋ทฐ์™€ ์—ฐ๊ด€๋œ ๋กœ์ง์ด ๋“ค์–ด๊ฐ€๊ฒŒ ๋œ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

๊ทธ๋ž˜์„œ ์ œ ์ˆ˜์ • ๋ฐฉ์•ˆ์œผ๋กœ๋Š”, ๋„๋ฉ”์ธ๊ณผ ๋ทฐ๊ฐ€ ์—ฐ๊ด€๋˜๋Š” ๊ฒƒ๋ณด๋‹ค๋Š” getter ์ง€์–‘์„ ์ผ๋ถ€ ํฌ๊ธฐํ•˜๋Š” ํŠธ๋ ˆ์ด๋“œ์˜คํ”„๋ฅผ ์„ ํƒํ•˜๋Š” ํŽธ์ด ๋‚ซ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ์Šต๋‹ˆ๋‹ค. ํ˜น์‹œ ๋‘ ๊ฐ€์ง€๋ฅผ ๋ชจ๋‘ ํฌ๊ธฐํ•˜์ง€ ์•Š๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ์„๊นŒ์š”?

์šฐ์„ ์€ getter๋ฅผ ์‚ฌ์šฉํ•ด Card ๋ฆฌ์ŠคํŠธ๋กœ ๋น„๊ตํ•˜๋„๋ก ์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.

Copy link

Choose a reason for hiding this comment

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

์ด๋ฏธ getter๋ฅผ ํ”„๋กœ๋•์…˜ ์ฝ”๋“œ(Controller)์—์„œ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๊ธฐ ๋•Œ๋ฌธ์— getter๋ฅผ ์‚ฌ์šฉํ•ด๋„ ๋œ๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. ๋งŒ์•ฝ์— ํ”„๋กœ๋•์…˜ ์ฝ”๋“œ์—๋„ getter๊ฐ€ ์—†์–ด ํ…Œ์ŠคํŠธ ์ฝ”๋“œ์—์„œ๋งŒ ์‚ฌ์šฉ๋œ๋‹ค๋ฉด ์กฐ๊ธˆ ๋ฒˆ๊ฑฐ๋กญ์ง€๋งŒ equals&hashcode๋ฅผ ์˜ค๋ฒ„๋ผ์ด๋“œํ•ด์„œ isEqualTo๋กœ ๊ฒ€์ฆํ•˜๋Š” ๊ฒƒ๋„ ๋ฐฉ๋ฒ•์ด ๋˜๊ฒ ๋„ค์š”.

yj9107v added 19 commits March 10, 2026 14:35
- ๋„๋ฉ”์ธ๊ณผ ๋ทฐ์˜ ์—ฐ๊ด€์„ฑ์„ ์—†์•ฐ
- ๋„๋ฉ”์ธ๊ณผ ๋ทฐ์˜ ์—ฐ๊ด€์„ฑ์„ ์—†์•ฐ
- ์นด๋“œ์˜ ํ™•์ธ์„ ์‚ฌ์ด์ฆˆ๋กœ ํ•˜์ง€ ์•Š๊ณ  Card ๋ฆฌ์ŠคํŠธ๋กœ ํ…Œ์ŠคํŠธ
- ํ”Œ๋ ˆ์ด์–ด๋“ค์˜ ์ ์ˆ˜๋ฅผ size๋กœ ํ…Œ์ŠคํŠธํ•˜์ง€ ์•Š๊ณ , List<Integer>๋กœ ๊ฒฐ๊ณผ ๊ฐ’ ํ…Œ์ŠคํŠธ ์ˆ˜์ •
- Policy ์ƒ์ˆ˜ํ™” ์˜ฎ๊น€
- count ๋ฐ˜ํ™˜ ๊ฐ’ ์‚ญ์ œ
- ์ ‘๊ทผ์ง€์ •์ž public -> private ์ˆ˜์ •
- ์ถ”์ƒํ™” ์ˆ˜์ค€์„ ๋†’์ด๊ธฐ ์œ„ํ•ด shuffled() ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€
- Player์˜ ๋ทฐ์™€ ์—ฐ๊ด€๋œgetCardsInfo() ํ˜ธ์ถœํ•˜์ง€ ์•Š๊ณ  getCards() ํ˜ธ์ถœ๋กœ ์ˆ˜์ •
- ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๋ฒ„์ŠคํŠธ์ธ ๊ฒฝ์šฐ ๋”œ๋Ÿฌ ์ ์ˆ˜์™€ ์ƒ๊ด€์—†์ด ํ”Œ๋ ˆ์ด์–ด ํŒจ๋ฐฐ
- ๋ทฐ ์—ฐ๊ด€๋œ ๋ฉ”์„œ๋“œ๋ฅผ ์ œ๊ฑฐ ํ›„ ํ•„๋“œ getter๋กœ ๋ณ€๊ฒฝ
Copy link

@verus-j verus-j left a comment

Choose a reason for hiding this comment

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

์•ˆ๋…•ํ•˜์„ธ์š” ์™€์ด์ œ๋ฆฌ~
ํ”ผ๋“œ๋ฐฑ ๋ฐ˜์˜ํ•˜๋А๋ผ ๊ณ ์ƒํ•˜์…จ์Šต๋‹ˆ๋‹ค. ์ถ”๊ฐ€ ํ”ผ๋“œ๋ฐฑ ๋‚จ๊ฒจ๋’€์œผ๋‹ˆ ํ™•์ธ๋ถ€ํƒ๋“œ๋ ค์š”!


public class Cards {

public static final int FIRST_DRAW_SIZE = 2;
Copy link

Choose a reason for hiding this comment

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

๋ณด๋‹ˆ๊น Controller์—์„œ ์‚ฌ์šฉ์ค‘์ด๋„ค์š”. FIRST_DRAW_SIZE๋ฅผ private์œผ๋กœ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ๋Š” ๊ตฌ์กฐ๊ฐ€ ์žˆ์„์ง€ ๊ณ ๋ฏผํ•ด๋ณด๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”. ์ดˆ๊ธฐ ์†ํŒจ ํฌ๊ธฐ์— ๋Œ€ํ•œ ์ •๋ณด๊ฐ€ public์œผ๋กœ ์œ ์ง€ํ•ด์•ผํ•œ๋‹ค๋ฉด, ์ดˆ๊ธฐ ์†ํŒจ์™€ ๊ด€๋ จ๋œ ๋กœ์ง์ด ์ด๊ณณ์ €๊ณณ์— ํฉ์–ด์ ธ ์žˆ์„ ๊ฐ€๋Šฅ์„ฑ์ด ํฐ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

return new BlackjackResult(dealer, players);
}

public void compareResult(Dealer dealer, Players players) {
Copy link

Choose a reason for hiding this comment

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

์ ‘๊ทผ ์ œ์–ด์ž ์ˆ˜์ •์ด ํ•„์š”ํ•ด๋ณด์ž…๋‹ˆ๋‹ค~

playerResult.put(player, WinOrLose.LOSE);
return;
}
playerResult.put(player, WinOrLose.DRAW);
Copy link

Choose a reason for hiding this comment

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

DRAW๊ฐ€ ์žˆ๋Š”๋ฐ WinOrLose๊ฐ€ ์˜ฌ๋ฐ”๋ฅธ enum ํด๋ž˜์Šค ์ด๋ฆ„์ผ๊นŒ์š”?

}
}

private void getJudgeResult(Dealer dealer, Player player) {
Copy link

Choose a reason for hiding this comment

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

๋ช‡๋ช‡ ๋ถ€๋ถ„ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๊ฐ€ ๋ถ€์กฑํ•ฉ๋‹ˆ๋‹ค! ํ™•์ธ๋ถ€ํƒ๋“œ๋ ค์š”~

Comment on lines +7 to +8
public static final int ACE_HIGH_LOW_DIFF = 10;
public static final int BUST_THRESHOLD = 21;
Copy link

Choose a reason for hiding this comment

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

์ ‘๊ทผ์ œ์–ด์ž ํ™•์ธ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค~

Comment on lines +7 to +9
public static final int DEALER_HIT_THRESHOLD = 16;
public static final int ACE_HIGH_LOW_DIFF = 10;
public static final int BUST_THRESHOLD = 21;
Copy link

Choose a reason for hiding this comment

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

์ ‘๊ทผ์ œ์–ด์ž ํ™•์ธ ๋ถ€ํƒ๋“œ๋ ค์š”~

Comment on lines +12 to +20
private final Cards deck = Cards.of();
private final List<Card> initialCards = new ArrayList<>(List.of(
Card.of(Rank.ACE, Suit.DIAMOND),
Card.of(Rank.FOUR, Suit.CLOVER)));

private final List<String> userNames = List.of("pobi", "jason");
private final Players players = Players.of(deck, userNames);
private final Dealer dealer = Dealer.of(initialCards);
private final BlackjackResult blackjackResult = BlackjackResult.of(dealer, players);
Copy link

Choose a reason for hiding this comment

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

given ์ ˆ์ด ์—ฌ๊ธฐ์— ๋‹ค ์žˆ์–ด์„œ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋ฅผ ์ฝ์„ ๋•Œ ์ดํ•ด๊ฐ€ ์–ด๋ ค์šธ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ์–ด๋–ป๊ฒŒ ํ•˜๋ฉด ์ค‘๋ณต๋œ ๋กœ์ง์„ ์ œ๊ฑฐํ•˜๋ฉด์„œ ๊ฐ€๋…์„ฑ ์žˆ๋Š” ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋ฅผ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ์„์ง€ ๊ณ ๋ฏผํ•ด๋ณด๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”~

Comment on lines +21 to +32
@Test
@DisplayName("๋”œ๋Ÿฌ ํ•ฉ๊ณ„๊ฐ€ 16์ดํ•˜์ด๋ฉด ์นด๋“œ 1์žฅ ์ถ”๊ฐ€ ํ…Œ์ŠคํŠธ")
void add_one_card_test() {
List<Card> initialCards = new ArrayList<>(List.of(
Card.of(Rank.ACE, Suit.DIAMOND),
Card.of(Rank.FOUR, Suit.CLOVER)));
Dealer dealer = Dealer.of(initialCards);

dealer.drawUntilHit(deck);

assertThat(dealer.getCards()).hasSize(3);
}
Copy link

Choose a reason for hiding this comment

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

๋‹ค์Œ์— ๋ฝ‘์€ ์นด๋“œ๊ฐ€ ACE์ด๋ฉด 4์žฅ๊นŒ์ง€ ๊ฐˆ ์ˆ˜ ์žˆ์ง€ ์•Š์„๊นŒ์š”?

Comment on lines +39 to +41
List<String> expect = List.of(Rank.TEN.getName() + Suit.DIAMOND.getName(),
Rank.FIVE.getName() + Suit.CLOVER.getName());
assertThat(player.getCardsInfo()).isEqualTo(expect);
Copy link

Choose a reason for hiding this comment

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

์ด๋ฏธ getter๋ฅผ ํ”„๋กœ๋•์…˜ ์ฝ”๋“œ(Controller)์—์„œ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๊ธฐ ๋•Œ๋ฌธ์— getter๋ฅผ ์‚ฌ์šฉํ•ด๋„ ๋œ๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. ๋งŒ์•ฝ์— ํ”„๋กœ๋•์…˜ ์ฝ”๋“œ์—๋„ getter๊ฐ€ ์—†์–ด ํ…Œ์ŠคํŠธ ์ฝ”๋“œ์—์„œ๋งŒ ์‚ฌ์šฉ๋œ๋‹ค๋ฉด ์กฐ๊ธˆ ๋ฒˆ๊ฑฐ๋กญ์ง€๋งŒ equals&hashcode๋ฅผ ์˜ค๋ฒ„๋ผ์ด๋“œํ•ด์„œ isEqualTo๋กœ ๊ฒ€์ฆํ•˜๋Š” ๊ฒƒ๋„ ๋ฐฉ๋ฒ•์ด ๋˜๊ฒ ๋„ค์š”.

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.

2 participants