Skip to content

Conversation

hughryu1125
Copy link

현재까지 작성한 부분까지 올립니다..ㅠㅠ

input 과정에서 빈칸을 사용자가 입력한 것으로 받아들이는 오류가 있습니다.
과제 요구 사항들을 많이 반영하지 못했습니다. (else 미사용, enum 사용, bonus number에 대한 잘못된 이해 등)

최대한 29일까지 완성해보겠습니다.

프로그래밍 요구 사항들을 다 반영시키지 못했습니다...
프로그래밍 요구 사항들을 다 반영시키지 못했습니다...
프로그래밍 요구 사항들을 다 반영시키지 못했습니다...
magic number
전체적 구조 변화
magic number
전체적 구조 변화
Copy link

@0702Yoon 0702Yoon left a comment

Choose a reason for hiding this comment

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

고생하셨습니다.
흥미로운 부분도 있었습니다.

전체적인 리뷰는 아니기에 제가 말한 것과 스스로 돌아보면서 고쳐보세요!

Comment on lines 11 to 14
Input input;
Output output;
Validator validator;
Calculator calculator;

Choose a reason for hiding this comment

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

접근제어자, final에 대해서 알고 계시나요??

Copy link
Author

Choose a reason for hiding this comment

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

다시 공부해보겠습니다..ㅠㅠㅠ

Choose a reason for hiding this comment

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

넵! 객체지향의 캡슐화를 지킬 수 있는 방법이여서 학습하시길!

public class Validator {

public void validateAmountOfMoney(int money){
if(money % 1000 != 0 || money < 0) throw new IllegalArgumentException();

Choose a reason for hiding this comment

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

매직 넘버 + 에외 이유도 적으면 더 좋을 것 같아요.

Copy link
Author

Choose a reason for hiding this comment

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

넵!!

System.out.println("구입하실 금액을 입력하세요: ");
}

public void printAskNumbers(){

Choose a reason for hiding this comment

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

메서도 네이밍이 모호한 것 같아요.

Copy link
Author

Choose a reason for hiding this comment

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

printAskWinningNumber()로 하면 괜찮을까요..?

inputNumbers.add(Integer.parseInt(input.trim()));
}

return inputNumbers; // validation하지 않은 raw값을 보냄.

Choose a reason for hiding this comment

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

이거는 검사하는 것을 아직 구현하지 않아서 주석 달으신거에요? 아니면 그냥 이 메서드를 설명하신건가요?

Copy link
Author

Choose a reason for hiding this comment

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

validator를 만들기 전에 작성한 코드라 그 주석이 있는 것 같습니다..

List<Integer> winningNumbers = input.readLottoNumbers();

output.printAskNumbers();
int bonusNumber = input.readBonusNumber();

Choose a reason for hiding this comment

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

보너스 번호도 검사를 일부러 안하신건가요?

Copy link
Author

Choose a reason for hiding this comment

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

이 부분은 까먹었습니다ㅠㅠ


public class BunchOfLotties {
int lottiesCount;
RandomNumberCreator randomCreator = new RandomNumberCreator(); // 이걸 instance로 진짜 해야돼?

Choose a reason for hiding this comment

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

필드 주입을 하신 이유가 무엇인가요?

Copy link
Author

Choose a reason for hiding this comment

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

외부에서 전체적인 로직을 알 필요 없다고 생각해서 숨기려고 했습니다..!
randomCreator도 FlowManager에서 가지고 있다가 함수 파라미터로 넣어주는게 적절할까요?

Choose a reason for hiding this comment

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

오호 의존성 주입에 대한 개념을 아시나요??
의도 자체는 굉장히 좋은 것 같아요.
소프트웨어에서는 BunchOfLotties가 RandomCreator를 사용할 때 직접 고르는 것을 선호하지 않거든요!
현우멘토님이 보내신 AppConfig를 한번 보시면 좋을 것 같아요

Copy link
Author

Choose a reason for hiding this comment

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

넵!! 더 공부해보겠습니다..!!

Comment on lines 31 to 35
int winnerCount = lotties.getWinnerCount(winningLotto);
int secondWinnerCount = lotties.get2ndWinnerCount(winningLotto);
int thirdWinnerCount = lotties.get3rdWinnerCount(winningLotto);
int fourthWinnerCount = lotties.get4thWinnerCount(winningLotto);
int fifthWinnerCount = lotties.get5thWinnerCount(winningLotto);

Choose a reason for hiding this comment

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

갑자기 잘 포장했다가 배를 가르셨어요.
그 이유가 뭐죠?

Copy link
Author

Choose a reason for hiding this comment

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

winnerCount를 비롯해 각각의 변수들이 이후 두 군데(결과 출력, 이윤 계산)에서 쓰여서 변수로 직접 선언했습니다. 매번 get함수로 불러오는 것은 적절하지 않은 것 같았습니다.

그리고 한 함수로 처리하지 않고 각 함수를 5개씩이나 만들게 됐던 건..
함수 하나로 하려다보니 list를 써야했고, list를 쓰면 아무래도 index부분이나, 가독성이 좋지 않을 것 같아서 모두 각기 다른 함수로 만들었습니다

이제 보니, list를 쓰는게 더 깔끔하고 가독성 부분도 괜찮았을 것 같습니다...

Choose a reason for hiding this comment

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

그러면 혹시 lotties가 결과, 이윤을 반환하는 건 별로였을까요??

Copy link
Author

Choose a reason for hiding this comment

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

lotties가 이윤을 반환하기 위해선 Calculator class를 가지고 있어야 하는데,
Calculator의 경우, 이윤을 계산하는 함수 뿐 아니라 다 함수도 가지고 있어서
lotties가 Calculator를 가지고 있는 것이 부적절하다고 느꼈습니다.

Calculator를 기능별로 더 분리해서 만들고, lotties가 Calculator를 가지는 구조가 적절할까요..??

Comment on lines 53 to 65
public int get3rdWinnerCount(WinningLotto winningLotto) {
List<Integer> winningNumbers = winningLotto.getNumbers();
int count = 0;
for(int i = 0; i < lottoList.size(); i++){
if (lottoList.get(i).getSameNumberCount(winningNumbers) == LOTTOINFO.MAX_LOTTO_COUNT-1
&& !lottoList.get(i).hasBonusNumber(winningLotto.getBonusNumber())){
count++;
}
}

return count;
}

Choose a reason for hiding this comment

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

get하실 때마다 특정 순위의 개수를 반환하는 것 같아요.
근데 그러면 전체 로또를 6번 돌아야 하기 때문에 조금 비효율적인 것 같아요.

Copy link
Author

Choose a reason for hiding this comment

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

이걸 한번에 검사해서 list로 반환하는게 좋을까요..?

Choose a reason for hiding this comment

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

네네
만약 로또가 10만개일 경우에는
1등부터 보너스 당첨자까지 확인할려면 70만개를 도는 거라서 다른 구현이 더 좋을 것 같아요!

Copy link

@baaamk baaamk left a comment

Choose a reason for hiding this comment

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

고생하셨습니다.

MVC에 대한 공부가 조금 더 필요하실 것 같습니다.
책임을 너무 분배한것이 아닌가?? 라는 생각도 드네요.

그럼에도 고민을 많이 하신게 정말 많이 보여서 기쁩니다!!
고생하셨어요!

AppConfig 잘 활용해서 리팩토링 해보세요!

Copy link

Choose a reason for hiding this comment

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

클래스 명 카멜 케이스 유의해주세요

Copy link

Choose a reason for hiding this comment

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

클래스 명 카멜 케이스 유의해주세요

Copy link

Choose a reason for hiding this comment

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

클래스 명 카멜 케이스 유의해주세요

Copy link

Choose a reason for hiding this comment

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

클래스 명 카멜 케이스 유의해주세요

Copy link

Choose a reason for hiding this comment

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

패키지 구조 유의해주세요

System.out.println(count + "개를 구매했습니다.");
System.out.print("[ ");
for(int i = 0; i < count; i++) {
if(i == count-1) System.out.print(numbers.get(i));
Copy link

Choose a reason for hiding this comment

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

저는 중괄호 생략을 별로 좋아하지 않는 편입니다..
다음에 협업하실때는 이런것 맞추는게 좋아보여용

Comment on lines +43 to +49
public void printMatchingResult(List<Integer> winnerCounts){
System.out.println("3개 일치 (5,000원) -- " + winnerCounts.get(WINNERCOUNT.WINNER) + "개");
System.out.println("4개 일치 (50,000원) -- " + winnerCounts.get(WINNERCOUNT.SECONDWINNER) + "개");
System.out.println("5개 일치 (1,500,000원) -- " + winnerCounts.get(WINNERCOUNT.THIRDWINNER) + "개");
System.out.println("5개 일치 + 보너스 숫자 일치 (30,000,000d원)" + winnerCounts.get(WINNERCOUNT.FOURTHWINNER) + "개");
System.out.println("6개 일치 (2,000,000,000원) -- " + winnerCounts.get(WINNERCOUNT.FIFTHWINNER) + "개");
}
Copy link

Choose a reason for hiding this comment

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

DTO 활용 고민해보시면 좋을 것 같습니다~

System.out.println(" ]");
}

public void printLotties(List<Lotto> lottoList){
Copy link

Choose a reason for hiding this comment

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

MVC 설계에서 View는 Model을 알면 안 되고, Model은 View를 알면 안 된다.
이 사실을 유의하면서 코드 짜보시면 좋을 것 같아요!

}


} No newline at end of file
Copy link

Choose a reason for hiding this comment

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

}

private void printLotto(List<Integer> numbers){
int count = numbers.size(); // 과연 이게 좋을까?? 이미 로또의 사이즈가 확정적으로 정해져있음.. 그치만 혹시 모를 상황을 생각해서 일단 이렇게 함...
Copy link

Choose a reason for hiding this comment

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

이걸 생각하셨다면 input에서 최소한의 검증은 해주시는게 좋습니다.
숫자가 6개가 들어왔는지와 같은 input 검증이요!

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