Skip to content

Conversation

@kay019
Copy link

@kay019 kay019 commented Jan 4, 2026

No description provided.

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.

4단계 미션 진행 👍
4단계에서 인터페이스 활용에 대해 경험해 보면 좋을 것 같아 피드백 남겼어요.
추가로 lotto 패키지에 도메인 객체 수가 늘어나고 있는데요.
패키지 분리도 도전해 보면 어떨까요?

import java.util.List;
import java.util.stream.IntStream;

public class ShuffleNumberGenerator implements LottoNumberGenerator{
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 class ShuffleNumberGenerator implements LottoNumberGenerator{
public class ShuffleNumberGenerator implements LottoNumberGenerator {

Comment on lines 20 to 22
List<Lotto> manualLottos = readManualLottos(manualCount);

Lottos issued = issueAll(money, manualCount, manualLottos);
Copy link
Contributor

Choose a reason for hiding this comment

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

3단계에서 4단계로 요구사항이 변경될 때 로또를 생성하는 부분의 요구사항만 변경됐다.
로또를 생성하는 부분을 다음과 같은 구조의 인터페이스로 분리해 보는 연습을 해보면 어떨까?
이와 같이 인터페이스로 구현했을 때의 잇점에 대해 고민해 보는 시간을 가져본다.
Lottos는 사용자가 구매한 n장의 로또를 추상화한 객체임

public interface LottosGenerator {
    Lottos generate();
}

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하려다 하나만 더 도전해 봤으면 하는 바람으로 피드백 남겨 봅니다.

import lotto.domain.Lotto;
import lotto.domain.Lottos;

public class MixedLottosGenerator implements LottosGenerator {
Copy link
Contributor

Choose a reason for hiding this comment

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

보통 디자인 패턴에서 컴포지트 패턴으로 알려져 있는 패턴 적용 👍
단, 이 객체를 아래와 같은 구조로 구현해 보면 어떨까?

public class LottosBundleGenerator implements LottosGenerator {
    private final List<LottosGenerator> lottosGenerators;

    public LottosBundleGenerator(Money money, List<String> manualLottoText) {
        this(toLottosGenerators(money, manualLottoText));
    }

    private static List<LottosGenerator> toLottosGenerators(Money money, List<String> manualLottoText) {
        // manualLottoText 활용해 ManualLottosGenerator 생성
        // money에서 수동으로 구매한 로또 수 만큼 차감한 후 AutoLottosGenerator 생성
    }

    public LottosBundleGenerator(List<LottosGenerator> lottosGenerators) {
        this.lottosGenerators = lottosGenerators;
    }

    @Override
    public Lottos generate() {
        // List<LottosGenerator> 반복문 돌며 로또 생성
        return  로또를 합쳐서 반환;
    }
}

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