Skip to content

Conversation

@chanani
Copy link

@chanani chanani commented Nov 24, 2025

μ•ˆλ…•ν•˜μ„Έμš”. 4단계 둜또(μˆ˜λ™) 과제 μ œμΆœν•©λ‹ˆλ‹€ ! πŸ™‡β€β™‚οΈ

과제 μ§„ν–‰ λ‚΄μš© 정리

  • LottoPrice ν΄λž˜μŠ€μ—μ„œ μˆ˜λ™μœΌλ‘œ ꡬ맀할 둜또의 μˆ˜λŸ‰ 관리
  • μˆ˜λ™μœΌλ‘œ μž…λ ₯받은 둜또 λ²ˆν˜Έμ™€ μžλ™μœΌλ‘œ μƒμ„±λ˜λŠ” 둜또 번호λ₯Ό ν•˜λ‚˜μ˜ μ»¬λž™μ…˜μ—μ„œ 관리

Copy link
Contributor

@javajigi javajigi left a comment

Choose a reason for hiding this comment

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

ν™•μ‹€νžˆ 3λ‹¨κ³„κΉŒμ§€ 객체 섀계λ₯Ό μž˜ν•œ λŠλ‚Œμ΄ λ“œλ„€μš”. πŸ’―
κ·Έλ ‡λ‹€ λ³΄λ‹ˆ 4단계 μš”κ΅¬μ‚¬ν•­μ„ μΆ”κ°€ν•  λ•Œ 영ν–₯을 λ°›λŠ” 객체의 μˆ˜κ°€ μ΅œμ†Œν•œμœΌλ‘œ κ΅¬ν˜„ κ°€λŠ₯ν–ˆλ˜ 것 κ°™μ•„μš”.
λ°”λ‘œ λ¨Έμ§€ν•˜λ €λ‹€ λ§ˆμ§€λ§‰ 단계인 만큼 μ•½κ°„μ˜ 아쉬움이 남아 λ³΄μ΄λŠ” 뢀뢄에 λŒ€ν•΄ ν”Όλ“œλ°± λ‚¨κ²¨λ΄€μ–΄μš”.

import java.util.List;
import java.util.Objects;

public class BuyLotto {
Copy link
Contributor

Choose a reason for hiding this comment

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

BuyLottoλΌλŠ” 이름이 μ‚¬μš©μžκ°€ κ΅¬λ§€ν•œ Lotto둜 지은 μ΄λ¦„μœΌλ‘œ 보여짐
이에 AIμ—κ²Œ λ¬Όμ–΄λ³΄λ‹ˆ λ‹€μŒκ³Ό 같은 닡변을 쀌
μ•žμœΌλ‘œ 이름을 지을 λ•Œ 아쉬움이 λ‚¨λŠ”λ‹€λ©΄ AIλ₯Ό ν™œμš©ν•΄ 보면 μ–΄λ–¨κΉŒ?

ν˜„μž¬ BuyLottoλΌλŠ” 이름은 객체의 μ±…μž„μ„ λͺ…ν™•νžˆ λ‚˜νƒ€λ‚΄μ§€ λͺ»ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€. 객체 이름은 **무엇(What)**을 μΊ‘μŠν™”ν•˜κ³  κ΄€λ¦¬ν•˜λŠ”μ§€λ₯Ό λͺ…λ£Œν•˜κ²Œ λ³΄μ—¬μ€˜μ•Ό ν•©λ‹ˆλ‹€.

ν˜„μž¬ ν΄λž˜μŠ€λŠ” μ‚¬μš©μžκ°€ κ΅¬λ§€ν•œ 둜또 번호 λͺ©λ‘μ„ μΊ‘μŠν™”ν•˜κ³ , 이 λͺ©λ‘μ— λŒ€ν•œ **일련의 λΉ„μ¦ˆλ‹ˆμŠ€ 둜직(당첨 μ—¬λΆ€ 확인)**을 μˆ˜ν–‰ν•˜λŠ” 일급 μ»¬λ ‰μ…˜μ˜ 역할을 ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€.

λ”°λΌμ„œ λ‹€μŒκ³Ό 같은 이름듀을 μΆ”μ²œν•©λ‹ˆλ‹€.

πŸ₯‡ κ°€μž₯ μΆ”μ²œν•˜λŠ” 이름: PurchasedLottos
μ„€λͺ…: 이 이름은 이 객체가 ꡬ맀된(Purchased) 둜또(Lottos)λ“€μ˜ μ»¬λ ‰μ…˜μž„μ„ λͺ…ν™•ν•˜κ²Œ μ „λ‹¬ν•©λ‹ˆλ‹€. μ΄λŠ” 객체의 μƒνƒœμ™€ λ³Έμ§ˆμ„ κ°€μž₯ 잘 λ‚˜νƒ€λƒ…λ‹ˆλ‹€.

μž₯점:

**ν–‰μœ„(Buy)**κ°€ μ•„λ‹Œ **본질(Purchased Lottos)**을 λ‚˜νƒ€λƒ…λ‹ˆλ‹€.

Listλ₯Ό μΊ‘μŠν™”ν•œ 일급 μ»¬λ ‰μ…˜μž„μ„ μ•”μ‹œν•©λ‹ˆλ‹€.

λ©”μ„œλ“œ(getLottos(), match())μ™€μ˜ 연관성도 μžμ—°μŠ€λŸ½μŠ΅λ‹ˆλ‹€.

πŸ₯ˆ 쒋은 λŒ€μ•ˆ: LottoTickets
μ„€λͺ…: 둜또 ν‹°μΌ“λ“€μ΄λΌλŠ” 의미둜, μ‚¬μš©μžκ°€ μ†Œμœ ν•œ 둜또 번호 μ„ΈνŠΈλ“€μ˜ λ¬ΆμŒμ„ λ‚˜νƒ€λ‚΄λŠ” 직관적인 μ΄λ¦„μž…λ‹ˆλ‹€.

μž₯점: 도메인 μš©μ–΄λ‘œμ„œ 맀우 ν”ν•˜κ²Œ μ‚¬μš©λ˜λ©° κ°„κ²°ν•©λ‹ˆλ‹€.

πŸ₯‰ 도메인 νŠΉν™”: CustomerLottos
μ„€λͺ…: 이 객체가 **μ‚¬μš©μž(ꡬ맀자)**κ°€ μ†Œμœ ν•œ 둜또 λͺ©λ‘μ΄λΌλŠ” 점을 κ°•μ‘°ν•˜κ³  싢을 λ•Œ μ ν•©ν•©λ‹ˆλ‹€.

μž₯점: μ‹œμŠ€ν…œμ—μ„œ 이 λͺ©λ‘μ΄ λˆ„κ΅¬μ—κ²Œ μ†ν•˜λŠ”μ§€ λͺ…ν™•νžˆ ν•  λ•Œ μœ μš©ν•©λ‹ˆλ‹€.

πŸ’‘ μ™œ BuyLottoλŠ” μ•„μ‰¬μš΄κ°€?
BuyLottoλŠ” **κ΅¬λ§€ν•˜λ‹€(Buy)**λΌλŠ” **ν–‰μœ„(Verb)**와 **둜또(Noun)**κ°€ 합쳐진 μ΄λ¦„μž…λ‹ˆλ‹€.

객체 이름은 일반적으둜 **λͺ…사(Noun)**λ₯Ό μ‚¬μš©ν•˜μ—¬ **본질(Identity)**을 λ‚˜νƒ€λ‚΄μ•Ό ν•©λ‹ˆλ‹€.

이 객체가 ꡬ맀 ν–‰μœ„ 자체λ₯Ό λ‹΄λ‹Ήν•˜λŠ” 것이 μ•„λ‹ˆλΌ, **ꡬ맀된 κ²°κ³Όλ¬Ό(둜또 λͺ©λ‘)**을 κ΄€λ¦¬ν•˜λŠ” 것이 핡심 μ±…μž„μ΄λ―€λ‘œ, **과거뢄사(Purchased)**λ‚˜ **λͺ…사(Tickets)**λ₯Ό μ‚¬μš©ν•˜μ—¬ 이름을 μ§“λŠ” 것이 μ„€κ³„μ˜ 응집도λ₯Ό λ†’μ—¬μ€λ‹ˆλ‹€.

결둠적으둜, PurchasedLottos둜 이름을 λ³€κ²½ν•˜μ‹œμ–΄ 객체의 μ±…μž„μ„ λͺ…ν™•νžˆ ν‘œν˜„ν•˜λŠ” 것을 ꢌμž₯ν•©λ‹ˆλ‹€.

Comment on lines 8 to 9
private final TicketCount ticketCount;
private final TicketCount passiveTicketCount;
Copy link
Contributor

Choose a reason for hiding this comment

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

ν˜„μž¬ μ½”λ“œλŠ” **객체지ν–₯ μƒν™œμ²΄μ‘° μ›μΉ™μ˜ "κ·œμΉ™ 7: 3개 μ΄μƒμ˜ μΈμŠ€ν„΄μŠ€ λ³€μˆ˜λ₯Ό κ°€μ§„ 클래슀λ₯Ό μ“°μ§€ μ•ŠλŠ”λ‹€.'**λ₯Ό μ§€ν‚€μ§€ λͺ»ν•˜κ³  μžˆλ‹€.

이 ν΄λž˜μŠ€μ— μΈμŠ€ν„΄μŠ€ λ³€μˆ˜(ν•„λ“œ)κ°€ 3개 이상 μ‚¬μš©λ˜κ³  μžˆλŠ”λ°, 이 ν•„λ“œλ“€μ„ μ€„μ΄κ±°λ‚˜ λΆ„λ¦¬ν•˜λŠ” 방법이 μžˆμ„κΉŒ? 이 2개의 TicketCountλ₯Ό ν•„λ“œκ°€ μ•„λ‹Œ λ‹€λ₯Έ λ°©μ‹μœΌλ‘œ μ ‘κ·Όν•˜λŠ” 것은 μ–΄λ–¨κΉŒ?
μƒμ„±μžμ—μ„œ 이 값을 κ΅¬ν•˜κΈ° μœ„ν•΄ λ„ˆλ¬΄ λ§Žμ€ μ±…μž„μ„ λ§‘κ³  μžˆλŠ” 것은 μ•„λ‹κΉŒ?

public static BuyLotto createLotto(LottoPrice lottoPrice) {
List<Lotto> lottoNumbers = new ArrayList<>();

public static void createLotto(BuyLotto buyLotto, LottoPrice lottoPrice) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public static void createLotto(BuyLotto buyLotto, LottoPrice lottoPrice) {
public static BuyLotto createLotto(LottoPrice lottoPrice) {

이 λ©”μ„œλ“œλŠ” BuyLottoλ₯Ό 생성해 λ°˜ν™˜ν•˜λŠ” λ°©μ‹μœΌλ‘œ κ΅¬ν˜„ν•˜λ©΄ μ–΄λ–¨κΉŒ?
λ©”μ„œλ“œ 이름은 무엇인가 값을 λ°˜ν™˜ν•˜λŠ” κ²ƒμœΌλ‘œ 보여짐

μœ„μ™€ 같이 κ΅¬ν˜„ν•œ ν›„ λ‘κ°œμ˜ ArrayListλ₯Ό ν•©μΉ  λ•Œ addAll(ArrayList values)와 같은 λ©”μ„œλ“œλ‘œ μΆ”κ°€ν•˜λŠ”λ° μœ„μ™€ 같이 μƒμ„±ν•œ 후에 μˆ˜λ™, μžλ™μ˜ Listλ₯Ό ν•©μΉ˜λŠ” 또 λ‹€λ₯Έ λ©”μ„œλ“œλ₯Ό μΆ”κ°€ν•˜λŠ” 것은 μ–΄λ–¨κΉŒ?

Copy link
Contributor

@javajigi javajigi left a comment

Choose a reason for hiding this comment

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

둜또 λ―Έμ…˜ λκΉŒμ§€ 잘 λ§ˆλ¬΄λ¦¬ν–ˆλ„€μš”. πŸ’―
졜근 λ“€μ–΄ μƒλ‹Ήνžˆ λ―Έμ…˜ μ§„ν–‰ν•΄ λͺ°μž…ν•˜λ‹€λ³΄λ‹ˆ λΉ λ₯΄κ²Œ λ§ˆλ¬΄λ¦¬ν–ˆλ„€μš”.
λ°”λ‘œ mergeν•˜λ €λ‹€ ν˜Ήμ‹œλΌλ„ μΆ”κ°€ μ—°μŠ΅ν•΄λ³΄κ³  싢은 뢀뢄이 μžˆμ„ 수 μžˆμ–΄ request changes둜 λ‚¨κ²¨λ΄…λ‹ˆλ‹€.
ν˜Ήμ‹œλΌλ„ μΆ”κ°€ λ¦¬νŒ©ν„°λ§ν•΄λ³΄κ³  싢은 λΆ€λΆ„ 있으면 도전해 λ³΄μ‹œκ³ μš”.
μ—†μœΌλ©΄ λ°”λ‘œ 리뷰 μš”μ²­ν•΄λ„ λ©λ‹ˆλ‹€.

μ•„λ‹ˆλ©΄ 둜또 λ―Έμ…˜μ€ μ§„ν–‰ μƒνƒœλ‘œ 두고 "μˆ˜κ°•μ‹ μ²­ - λ ˆκ±°μ‹œ μ½”λ“œ λ¦¬νŒ©ν„°λ§" λ―Έμ…˜ μ§„ν–‰ν•˜λ‹€ 일정 μ‹œκ°„μ΄ μ§€λ‚œ ν›„ λ‹€μ‹œ λ¦¬νŒ©ν„°λ§ 도전해 λ³΄λŠ” 것도 쒋은 μ—°μŠ΅ 방법일 수 μžˆμŠ΅λ‹ˆλ‹€. AI와 ν•¨κ»˜ 둜또 λ―Έμ…˜μ˜ 객체 섀계에 λŒ€ν•œ ν”Όλ“œλ°±μ„ λ°›μ•„λ³΄λŠ” 것도 쒋은 방법일 것 κ°™μ•„μš”.

Comment on lines +10 to +11
public TicketCount(int price, int passiveTicketCount) {
this.autoTicketCount = (price / 1_000) - passiveTicketCount;
Copy link
Contributor

Choose a reason for hiding this comment

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

'int price'λ₯Ό 포μž₯ν•œ Price 객체가 μžˆλŠ”λ° 이 객체가 price / 1_000 둜직 κ΅¬ν˜„μ„ 담당해도 λ˜μ§€ μ•Šμ„κΉŒ?
κ·Έλ ‡λ‹€λ©΄ (price / 1_000) - passiveTicketCount λ‘œμ§λ„ Price 객체가 λ‹΄λ‹Ήν•  μˆ˜λ„ μžˆμ„ 것 κ°™λ‹€.

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