Skip to content

[Team2 Pair1] 로또 Step1 완료#13

Open
westbro-zo wants to merge 1 commit into
wwh-techcamp-2018:team2_pair1from
westbro-zo:step1
Open

[Team2 Pair1] 로또 Step1 완료#13
westbro-zo wants to merge 1 commit into
wwh-techcamp-2018:team2_pair1from
westbro-zo:step1

Conversation

@westbro-zo
Copy link
Copy Markdown

불끄고 퇴근합니다 😂

Copy link
Copy Markdown
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.

전체적인 객체 설계는 나쁘지 않네요. enum을 좀 더 제대로 사용한다면 코드가 좀 더 깔끔해 질 것 같네요.

자바8의 stream, 람다 사용은 👍

map.put(5, 0);
map.put(6, 0);
return map;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

클래스의 구현 순서는 다음과 같다. 다음 원칙에 따라 구현한다.

class A {
    상수(static final) 또는 클래스 변수
    인스턴스 변수
    생성자
    메소드
}

return winningList(getIntegers(s));
}

private Map<Integer, Integer> winningList(List<Integer> list) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

List<Integer> list도 로또로 볼 수 있지 않을까?

}

public static List<Integer> createNumber() {
List<Integer> lotto = IntStream.rangeClosed(1, 45).boxed().collect(Collectors.toList());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Lotto를 생성할 때마다 매번 45개의 값을 생성할 필요가 있을까?
45개의 값 하나를 생성해 놓고 재사용할 수 없을까?

package lotto;

public enum WinPrize {
_3(5000), _4(50000), _5(1500000), _6(2000000000);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

enum은 "_"를 사용하기 보다 대문자로 사용하는 것이 일반적임
FIRST와 같이 등수를 사용하면 어떨까?

Copy link
Copy Markdown

@ryuneeee ryuneeee Jul 5, 2018

Choose a reason for hiding this comment

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

처음에 저희도 일반적으로 values()로 Loop을 도는것을 생각을 했는데요.
별도의 Loop을 돌지 않는 간결한 코드, O(N) -> O(1)로 Time Complexity를 줄인다는 목적(사실 속도면에서 의미 있을까 싶지만)으로 이렇게 설계를 진행 했습니다만, 다시보니 valueOf에서 String을 새롭게 만드는 작업이 더 오래걸릴꺼 같군요 ㅠ.ㅠ

return winnerNumbers.stream()
.filter(t -> numbers.contains(t))
.collect(Collectors.toList())
.size();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

.collect(Collectors.toList()) 사용하지 말고 filter().count() 가능하지 않나?

public static final int LOTTO_PRICE = 1000;

private final List<Lotto> lottos;
private final Map<Integer, Integer> map;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

굳이 인스턴스 변수로 구현할 필요가 있나?

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