Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step2 auto #4036

Merged
merged 5 commits into from
Mar 27, 2025
Merged

Step2 auto #4036

merged 5 commits into from
Mar 27, 2025

Conversation

bourbonkk
Copy link

Step 2 기능 요구사항

  • 사용자는 구입 금액을 입력할 수 있다.
  • 구입 금액에 따라 해당 개수의 로또를 자동 발급해야 한다.
  • 로또 1장의 가격은 1000원이다.
  • 발급된 각 로또는 서로 다른 6개의 숫자(1~45 사이)로 구성되어야 한다.
  • 발급된 로또 목록을 출력한다.
  • 사용자로부터 지난 주 당첨 번호 6개를 입력받는다. 중복 없이 6개의 숫자를 입력해야 하며, 숫자는 1~45 사이여야 한다.
  • 발급된 로또들에 대해 당첨 번호와의 일치 개수를 계산한다.
  • 아래와 같은 기준으로 일치하는 로또 개수 통계를 출력한다:
    • 3개 5,000원
    • 4개 50,000원
    • 5개 1,500,000원
    • 6개 2,000,000,000원
  • 수익률을 계산해 출력한다. 수익률은 (당첨금-구입금액)/구입금액 으로 계산한다.
  • 수익률 결과에 대해 기준이 1이라는 안내 메시지를 출력한다.

Step 2 힌트

  • 로또 자동 생성은 Collections.shuffle() 메소드 활용한다.
  • Collections.sort() 메소드를 활용해 정렬 가능하다.
  • ArrayList의 contains() 메소드를 활용하면 어떤 값이 존재하는지 유무를 판단할 수 있다.

Copy link
Member

@nooose nooose left a comment

Choose a reason for hiding this comment

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

민석님, 안녕하세요.
리뷰가 늦어서 죄송합니다.
이번 구현 정말 잘해주셨네요! 💯
넘어갈지 고민을 많이하다가 이번 단계에서 한번 더 보기로 했어요
코멘트 확인 후 재요청 부탁드립니다!
수고하셨습니다!

Lotto lastWeekLotto = new Lotto(Arrays.asList(1, 2, 3, 4, 5, 6));

Lottos lottos = new Lottos(List.of(
new Lotto(Arrays.asList(1, 2, 3, 7, 8, 9)), // 3개 일치 → 5000
Copy link
Member

Choose a reason for hiding this comment

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

List.ofArrays.asList 차이에 대해 알고 계시나요?

Copy link
Author

Choose a reason for hiding this comment

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

이참에 공부했습니다 감사합니다

@bourbonkk bourbonkk requested a review from nooose March 27, 2025 04:40
Copy link
Member

@nooose nooose left a comment

Choose a reason for hiding this comment

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

민석님 피드백 반영까지 잘 해주셨네요 👍
코멘트 남기면서 머지하겠습니다.
수고하셨습니다!


public double getProfitRate(int paidMoney) {
// lottoCount * 1000 = 총 투자금
int lottoCount = paidMoney / 1000;
Copy link
Member

Choose a reason for hiding this comment

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

로또 금액 1000원이 이곳저곳에서 사용되므로
상수화 시켜서 관리하면 좋지 않을까요?

Comment on lines +46 to +53
private List<Integer> convertStringToList(String lastWeekLottoResult) {
String[] split = lastWeekLottoResult.trim().split(",");
List<Integer> integerList = new ArrayList<>();
for (String s : split) {
integerList.add(Integer.parseInt(s.trim()));
}
return integerList;
}
Copy link
Member

Choose a reason for hiding this comment

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

Lotto 애플리케이션 중심으로 봤을 때
해당 로직은 view 영역의 책임으로 이동시키는 게 나을 것 같다는 의견을 드리고 싶어요

InputView는 단순 콘솔 입력만을 처리하는 것이 아닌
비즈니스 로직을 처리하기 전 데이터를 전처리해주는 영역으로 생각해도 되지 않을까요?
민석님의 의견은 어떤가요?

Copy link
Author

Choose a reason for hiding this comment

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

좋은것같습니다. 의견감사합니다.

@nooose nooose merged commit 99e6ba1 into next-step:bourbonkk Mar 27, 2025
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