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

πŸš€ 4단계 - 둜또(μˆ˜λ™) #3550

Open
wants to merge 6 commits into
base: gkssk4163
Choose a base branch
from

Conversation

gkssk4163
Copy link

@gkssk4163 gkssk4163 commented Dec 3, 2023

3단계 ν”Όλ“œλ°± 반영 및 4단계 κΈ°λŠ₯κ΅¬ν˜„ μ™„λ£Œν•˜μ—¬ λ¦¬λ·°μš”μ²­λ“œλ¦½λ‹ˆλ‹€~!

- λ©”μ‹œμ§€ λ³΄λ‚΄λŠ” λ°©μ‹μœΌλ‘œ λ³€κ²½
- μ˜ˆμ™Έλ©”μ„Έμ§€ μΆ”κ°€
- λ©”μ„œλ“œ 레퍼런슀 적용
- unmodifiableSet 적용
- λΆˆν•„μš”ν•œ ν•¨μˆ˜ 호좜 제거
Copy link

@csh0034 csh0034 left a comment

Choose a reason for hiding this comment

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

4단계 잘 κ΅¬ν˜„ν•΄μ£Όμ…¨λ„€μš” πŸ‘
λͺ‡κ°€μ§€ 고민해볼사항 λ‚¨κ²¨λ‘μ—ˆλŠ”λ°
확인후에 λ‹€μ‹œ λ¦¬λ·°μš”μ²­ λΆ€νƒλ“œλ €μš”!

@@ -13,10 +13,10 @@ public WinningLotto(Lotto winningLotto, LottoNumber bonus) {

private void validate() {
Copy link

Choose a reason for hiding this comment

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

numbers() λ₯Ό κΊΌλ‚΄μ™€μ„œ 순회λ₯Ό ν•˜κ³  μžˆμ§€λ§Œ μ‹€μ œ winningLottoNumber λŠ”
μ‚¬μš©ν•˜κ³  μžˆμ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

ν•˜λ‹¨κ³Ό 같이 μ²˜λ¦¬ν•΄λ³Όμˆ˜ μžˆμ§€ μ•Šμ„κΉŒμš”?

if (winningLotto.hasNumber(this.bonus)) {
    // μ˜ˆμ™Έ λ°œμƒ
}

this.numbers = new TreeSet<>(parseLottoNumber(numbers));
validate();
}

public Lotto(Integer... numbers) {
this(Arrays.asList(numbers));
this(Set.copyOf(Arrays.asList(numbers)));
Copy link

Choose a reason for hiding this comment

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

Suggested change
this(Set.copyOf(Arrays.asList(numbers)));
this(Set.of(numbers));

@@ -1,7 +1,7 @@
package lotto.domain;
Copy link

Choose a reason for hiding this comment

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

LottoNumber 에 변경사항이 μ—†μ–΄ 여기에 λ‚¨κ²¨λ†“μŠ΅λ‹ˆλ‹€.

LottoNumber 의 경우 1~45 의 숫자이기 λ•Œλ¬Έμ— 맀번 μΈμŠ€ν„΄μŠ€λ₯Ό μƒμ„±ν•˜μ§€μ•Šκ³ 
μΊμ‹±μ²˜λ¦¬ν•˜μ—¬ κ°™μ€λ²ˆν˜Έμ— λŒ€ν•΄μ„  같은 μΈμŠ€ν„΄μŠ€λ₯Ό μ‚¬μš©ν•΄λ³Όμˆ˜ μžˆμ„κ²ƒ κ°™μ•„μš”.

둜또 ν”Όλ“œλ°± - α„Œα…₯α†Όα„Œα…₯ᆨ ᄑᅒᆨ토라 메소드, 안스ᄐα…₯ᆫ스 ᄏᅒ상 을 μ°Έκ³ ν•˜μ—¬ μ μš©ν•΄λ³΄λ©΄ 쒋을것 κ°™μŠ΅λ‹ˆλ‹€.

import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class LottoBundle {

private static final int LOTTO_PRICE = 1000;

private final List<Lotto> lottoList;
private final List<Lotto> manualLottoList;
Copy link

Choose a reason for hiding this comment

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

LottoBundle 에선 μˆ˜λ™μΈμ§€ μžλ™μΈμ§€ ꡬ뢄없이 ν•˜λ‚˜μ˜ μ»¬λ ‰μ…˜μœΌλ‘œ κ΄€λ¦¬ν•΄λ„λ˜μ§€ μ•Šμ„κΉŒμš”? πŸ€”
μ •μ νŒ©ν† λ¦¬ λ©”μ„œλ“œλ₯Ό ν™œμš©ν•˜μ—¬ μƒμ„±ν•΄μ•Όν•˜λŠ” μžλ™λ‘œλ˜ + μˆ˜λ™μƒμ„±λœ 둜또λ₯Ό λ”ν•΄μ„œ λͺ©λ‘μ„
λ§Œλ“€λ„λ‘ ν•΄λ³Όμˆ˜λ„ μžˆμ„κ²ƒ κ°™μŠ΅λ‹ˆλ‹€.

import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.*;
import java.util.stream.Collectors;

public class InputView {
Copy link

Choose a reason for hiding this comment

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

μš”κ΅¬μ‚¬ν•­

  • μ˜ˆμ™Έ 처리λ₯Ό 톡해 μ—λŸ¬κ°€ λ°œμƒν•˜μ§€ μ•Šλ„λ‘ ν•œλ‹€.

힌트

  • μ‚¬μš©μžκ°€ 잘λͺ»λœ 값을 μž…λ ₯ν–ˆμ„ λ•Œ java exception으둜 μ—λŸ¬ 처리λ₯Ό ν•œλ‹€.

μƒλ‹¨μ˜ μš”κ΅¬μ‚¬ν•­μ— 맞좰 μž…λ ₯λ‹¨κ³„μ—μ„œ μ˜ˆμ™Έκ°€ λ°œμƒν•˜μ§€ μ•Šλ„λ‘
try catch ꡬ문을 ν™œμš©ν•˜μ—¬ μž¬μž…λ ₯을 받도둝 해보면 쒋을것 κ°™μŠ΅λ‹ˆλ‹€.

Arguments.of(Arrays.asList(1, 2, 3, 4, 5, 7), LottoResult.BONUS),
Arguments.of(Arrays.asList(1, 2, 3, 4, 5, 6), LottoResult.SIX),
Arguments.of(Arrays.asList(6, 7, 8, 9, 10, 11), LottoResult.FAIL)
Arguments.of(new Integer[]{1, 3, 5, 7, 9, 11}, LottoResult.THREE),
Copy link

Choose a reason for hiding this comment

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

ν•˜λ‹¨κ³Ό 같이 μ£Όμƒμ„±μžλ₯Ό μ΄μš©ν•˜κ²Œ ν•΄λ³Όμˆ˜λ„ μžˆμ„κ²ƒ κ°™μŠ΅λ‹ˆλ‹€!

Suggested change
Arguments.of(new Integer[]{1, 3, 5, 7, 9, 11}, LottoResult.THREE),
Arguments.of(Set.of(1, 3, 5, 7, 9, 11)}, LottoResult.THREE)

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