Donโ€™t talk to strangers!๐Ÿคซ

๋””๋ฏธํ„ฐ์˜ ๋ฒ•์น™

๋ธ”๋ž™์žญ ๋ฏธ์…˜์—์„œ ๊ฒฐ๊ณผ๋ฅผ ์ถœ๋ ฅํ• ๋•Œ ๋”œ๋Ÿฌ์˜ ์ฒซ๋ฒˆ์งธ ์นด๋“œ๋งŒ ์ถœ๋ ฅํ•ด์•ผ ํ•˜๋Š” ๋ถ€๋ถ„์„ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ผ๋‹ค๊ฐ€ ๋ฆฌ๋ทฐ์—์„œ ๋””๋ฏธํ„ฐ์˜ ๋ฒ•์น™์„ ๊ณต๋ถ€ํ•ด๋ณด๋ผ๋Š” ์ œ์•ˆ์„ ๋ฐ›์•„ ๊ธ€์„ ์“ฐ๊ฒŒ ๋˜์—ˆ๋‹ค.

dealer.cards.get(0).getDenomination()

๋””๋ฏธํ„ฐ์˜ ๋ฒ•์น™์ด๋ž€?

์œ„ํ‚ค์—์„œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ด์•ผ๊ธฐํ•œ๋‹ค.

  • Each unit should have only limited knowledge about other units: only units "closely" related to the current unit.
  • Each unit should only talk to its friends; don't talk to strangers.
  • Only talk to your immediate friends.

์ธ์šฉ๊ตฌ ์“ฐ๋Š”๊ฒŒ ๋ฉ‹์žˆ์–ด์„œ ๋”ฐ๋ผํ•ด๋ณด๊ณ  ์‹ถ์—ˆ๋‹ค.

๋ญ ๊ฐ€๊นŒ์šด ์นœ๊ตฌ๋ž‘๋งŒ ์–˜๊ธฐํ•˜๋ผ๋Š”๋ฐ ๊ฒฐ๊ตญ ์ธ์ ‘ํ•œ ๊ฐ์ฒด๋ผ๋ฆฌ๋งŒ ์„œ๋กœ๋ฅผ ์•Œ๊ณ ์žˆ๊ณ , ์ข€ ๋จผ ๊ฐ์ฒด๊ฐ€ ์–ด๋– ํ•œ ์ž๋ฃŒ๋ฅผ ๊ฐ–๊ณ  ์žˆ๋Š”์ง€๋Š” ๋ชฐ๋ผ์•ผ ํ•œ๋‹ค๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•œ๋‹ค.

์™œ ์ง€์ผœ์•ผํ•˜๋‚˜?

๊ฒฐํ•ฉ๋„์™€ ์บก์Šํ™”์—์„œ ๋ฌธ์ œ๊ฐ€ ์ƒ๊ธฐ๋Š”๋ฐ, ๊ฐ์ฒด๊ฐ€ ๋‹ค๋ฅธ ๊ฐ์ฒด์˜ ์š”์†Œ๋ฅผ ์ง์ ‘ ๊ฐ€์ ธ์˜ค๋ฉด ์„œ๋กœ ๋„ˆ๋ฌด ๋‹จ๋‹จํ•˜๊ฒŒ ์–ฝํ˜€์„œ ๋ณ€ํ™”์— ์œ ์—ฐํ•ด์ง€์ง€ ๋ชปํ•˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. ๋˜ํ•œ ์ €๋ ‡๊ฒŒ ๊ณ„์† get์œผ๋กœ ๋“ค์–ด๊ฐ€๋ฉด ๊ฐ์ฒด์˜ ์ •๋ณด๊ฐ€ ๋ถˆํ•„์š”ํ•˜๊ฒŒ ๋…ธ์ถœ๋œ๋‹ค.

๊ทธ๋Ÿผ ์–ด๋–ป๊ฒŒ ์ง€ํ‚ค๋‚˜?

์ง๊ด€์ ์œผ๋กœ๋Š” ์ ์„ ํ•œ๋ฒˆ๋งŒ ์ฐ์œผ๋ฉด ๋œ๋‹ค.

dealer.getCards.getDeck().get(0)

์ด๊ฑฐ์—์„œ

dealer.getFisrtCard();

getFirstCard(){
    return cards.getFirst();
}

getFirst(){
    return deck.get(0)
}

์ด๋Ÿฐ์‹์œผ๋กœ ๋ฉ”์†Œ๋“œ๋กœ ๋ถ„๋ฆฌํ•ด์ฃผ๋ฉด ๋œ๋‹ค.
๊ทธ๋ฆฌ๊ณ  ์ด ๋ฉ”์†Œ๋“œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ทœ์น™์„ ์ ์šฉํ–ˆ์„๋•Œ ๋ชจ๋“  ๊ทœ์น™์„ ๋งŒ์กฑํ•ด์•ผํ•œ๋‹ค.

  1. ๊ฐ์ฒด ์ž์‹ ์˜ ๋ฉ”์„œ๋“œ์ธ๊ฐ€?
  2. ๋ฉ”์„œ๋“œ์˜ ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ ๋„˜์–ด์˜จ ๊ฐ์ฒด๋“ค์˜ ๋ฉ”์„œ๋“œ์ธ๊ฐ€?
  3. ๋ฉ”์„œ๋“œ ๋‚ด๋ถ€์—์„œ ์ƒ์„ฑ, ์ดˆ๊ธฐํ™”๋œ ๊ฐ์ฒด์˜ ๋ฉ”์„œ๋“œ์ธ๊ฐ€?
  4. ์ธ์Šคํ„ด์Šค ๋ณ€์ˆ˜๋กœ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๊ฐ์ฒด๊ฐ€ ์†Œ์œ ํ•œ ๋ฉ”์„œ๋“œ์ธ๊ฐ€?

๋ณต์žกํ•ด ๋ณด์ด์ง€๋งŒ.. ๊ฒฐ๊ตญ ๊ฐ์ฒด๊ฐ€ ํ˜ธ์ถœ์‹œ์ ์— ์ง์ ‘์ ์œผ๋กœ ๊ฐ€์ง€๊ณ ์žˆ๋Š” ๊ฐ์ฒด์ธ๊ฐ€๋ฅผ ๋”ฐ์ง€๊ธฐ๋งŒ ํ•˜๋ฉด ๋œ๋‹ค. ์ƒ๊ฐํ•ด๋ณด๋‹ˆ ๊ฐ์ฒด๊ฐ„ ๋ฉ”์„ธ์ง€๋ฅผ ๋ณด๋‚ด๊ณ  getter ์‚ฌ์šฉ์„ ์ตœ์†Œํ™”ํ•˜๋ผ๋Š” ๊ฒƒ๊ณผ ๋‚˜๋ฆ„ ์ผ๋งฅ์ƒํ†ตํ•œ ์ด์•ผ๊ธฐ์ธ๋“ฏ ํ•˜๋‹ค.

๋‹จ์ 

๊ฐ์‹ธ๋Š” ๋ฉ”์†Œ๋“œ๊ฐ€ ๋„ˆ๋ฌด ๋งŽ์•„์ ธ์„œ ๋” ๋ณต์žกํ•ด์งˆ ์ˆ˜ ์žˆ๋‹ค.
๊ทœ์น™์„ ์œ„๋ฐฐํ•˜์ง€ ์•Š๋Š” ์„ ์—์„œ ์ตœ๋Œ€ํ•œ ์ ๊ฒŒ ์ชผ๊ฐค ๊ฒƒ

+) ์ŠคํŠธ๋ฆผ์€ ์  ๋งŽ์ด ์ฐ๋Š”๋ฐ ๋””๋ฏธํ„ฐ์˜ ๋ฒ•์น™ ์œ„๋ฐ˜์ธ๊ฐ€?

๋””๋ฏธํ„ฐ์˜ ๋ฒ•์น™์€ "๊ฐ์ฒด๊ฐ€ ์„œ๋กœ๋ฅผ ์–ผ๋งˆ๋‚˜ ๋งŽ์ด ์•Œ๊ณ ์žˆ๋Š๋ƒ"๋กœ ์ค€์ˆ˜์—ฌ๋ถ€๊ฐ€ ๊ฐˆ๋ฆฌ๊ธฐ ๋•Œ๋ฌธ์— ์ ์„ ์ฐ์Œ์œผ๋กœ์จ ๊ฐ์ฒด์˜ ๋‚ด๋ถ€๊ตฌํ˜„์„ ๋…ธ์ถœํ•˜์ง€ ์•Š๋Š” ํ•œ ํ•ด๋‹น๋˜์ง€ ์•Š๋Š” ์ด์•ผ๊ธฐ๋‹ค.

+) ์ž๋ฃŒ๊ตฌ์กฐ์—์„œ ์“ฐ๋ ค๋ฉด ๊ผญ ๋ถˆ๋Ÿฌ์•ผํ•˜๋Š” ๊ฒฝ์šฐ๋„ ์žˆ๋˜๋ฐ ์จ๋„ ๋˜๋‚˜?

์ด๋•Œ๋Š” ๋ถˆ๋Ÿฌ๋„ ๋œ๋‹ค! ๋งŒ์•ฝ ๋ฌป๋Š” ๋Œ€์ƒ์ด ๊ฐ์ฒด๊ฐ€ ์•„๋‹Œ ์ž๋ฃŒ๊ตฌ์กฐ๋ผ๋ฉด ๋‚ด๋ถ€๋ฅผ ๋…ธ์ถœํ•ด์•ผ ํ•˜๋ฏ€๋กœ ๋””๋ฏธํ„ฐ์˜ ๋ฒ•์น™์„ ์ ์šฉํ•  ํ•„์š”๊ฐ€ ์—†๋‹ค.

์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ