Skip to content

PR#1

Open
opdshe wants to merge 20 commits into
OOP-study-media:masterfrom
opdshe:dongheon
Open

PR#1
opdshe wants to merge 20 commits into
OOP-study-media:masterfrom
opdshe:dongheon

Conversation

@opdshe
Copy link
Copy Markdown

@opdshe opdshe commented Apr 12, 2020

No description provided.

Comment thread src/main/java/domain/Lotto.java Outdated
}
}

public void createNumbers() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Lotto의 생성자에서만 사용하는 것 같은데, 접근제어자를 private으로 해야하지 않을까?
그리고 보통 private메서드는 클래스에서 사용되는 순서대로 위치시켜
public ex1() { ex2(); ex3(); }
private ex2() { ... }
private ex3() { ... }

Comment thread src/main/java/domain/Lotto.java Outdated
}

public List<Integer> getNumbers() {
return numbers;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

보통 클래스의 필드를 private으로 선언하고, get메서드를 이용하는 이유는 뭘까?
그리고, 여기서 문제가 될 만한 요소는 뭐가 있을지 한번 생각해봐

Comment thread src/main/java/domain/WinningLotto.java Outdated
this.bonusNo = bonusNo;
}

public int countOfMatch(Lotto userlotto) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

파라미터 이름은 camel case 규칙을 지켜야돼.

Comment thread src/main/java/domain/WinningLotto.java Outdated
public int countOfMatch(Lotto userlotto) {
int countOfMatch = 0;
for (Integer integer : userlotto.getNumbers()) {
if (lotto.getNumbers().contains(integer)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

indent depth는 1까지만 허용되는 규칙이 있어.
userLotto에서 숫자를 꺼내지말고, Lotto 객체에 메시지를 보내도록 수정하면 어떨까?

Comment thread src/main/java/domain/WinningLotto.java Outdated
return countOfMatch;
}

public boolean isContainsBounus(Lotto userLotto) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

iscontains의 의미가 중복돼.
containsBonusNumber가 좋을 것 같아.

Comment thread src/main/java/lotto/App.java Outdated
do {
System.out.println("지난 주 당첨 번호를 입력해 주세요.");
answers = Arrays.stream(sc.nextLine().split(","))
.map(String::trim).map(Integer::parseInt).distinct()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

.마다 줄 바꿈을 해주면 가독성이 더 좋아져
10라인 맞추려고 이렇게 한거면, 보너스볼 입력을 따로 메서드로 분리시켜도 될 것 같은데?

Comment thread src/main/java/lotto/App.java Outdated

public static void printLottos() {
System.out.println(purchasingAmount / LOTTO_PRICE + "개를 구매했습니다.");
for (Lotto lotto : lottos) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

lottos.foreach( ... ) 를 사용해봐

Comment thread src/main/java/lotto/App.java Outdated

public static void initLottos() {
for (int i = 0; i < purchasingAmount / LOTTO_PRICE; i++) {
lottos.add(new Lotto(new ArrayList<>()));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

로또 객체를 생성할 때, 빈 리스트가 아니라 숫자가 들어있는 리스트를 넘길 수는 없을까?

Comment thread src/main/java/lotto/App.java Outdated
}
}

public static void printRankCount() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

이 메서드의 내용이 길어지는 이유는 당첨을 계산하는 로직과 출력하는 로직이 모두 포함되어있어서 인 것 같아.
각각 분리하면 어떨까?

Comment thread src/main/java/lotto/App.java Outdated

public static void setAnswers() {
private static void initLottos() {
for (int i = 0; i < purchasingAmount / LOTTO_PRICE; i++) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

for 문 안에 i < purchasingAmount / LOTTO_PRICE 되어있으면 매번 돌때마다 i < purchasingAmount / LOTTO_PRICE를 계산해서 반복할지를 판단하게 되는데, 매번 계산할 필요가 있을까?

Comment thread src/main/java/lotto/App.java Outdated
do {
System.out.println("지난 주 당첨 번호를 입력해 주세요.");
answers = Arrays.stream(sc.nextLine()
.split(","))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Arrays.stream(sc.nextLine().split(","))
.map(String:trim)
.map(Integer::parseInt))
.distinct()
.collect(Collectors.toList());

첫줄에는 스트림으로 바꾸는 코드를 작성하고, 스트림 api별로 줄바꿈을 해주면 어떤 작업이 이뤄지는지 명확하게 보일 것 같아

Comment thread src/main/java/lotto/App.java Outdated
private static void setBonusNum() {
do {
System.out.println("보너스 볼을 입력해 주세요.");
} while (!checkBonusNum(answers, bonusNum = sc.nextInt()));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

do {
    System.out.println("보너스 볼을 입력해 주세요.");
    bonusNum = sc.nextInt();
} while (!checkBonusNum(answers, bonusNum));

이게 낫지않을까??

private static Map<Rank, Integer> result = new TreeMap<>();
private static int purchasingAmount;
private static int bonusNum;
private static int prizeMoney;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

App클래스의 필드로 선언하는 변수의 갯수를 줄여볼 수 있을까?

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.

1 participant