[java-lotto] roki.kim(김경록) 과제 제출합니다.#1
[java-lotto] roki.kim(김경록) 과제 제출합니다.#1KimGyeongLock wants to merge 9 commits intoJapring-Study:mainfrom
Conversation
src/main/java/lotto/GameManager.java
Outdated
| */ | ||
| public void start() { | ||
| int money = lottoInputView.receiveUserMoneyInput(); | ||
| List<Lotto> lottoList = lottoService.generateLottoNumber(money / 1000); |
There was a problem hiding this comment.
숫자를 바로 하드코딩 하는 방식은 좋지 않은걸로 알고있는데 이 점에 대해선 어떻게 생각하시나용??
There was a problem hiding this comment.
magic number를 사용하는 방법으로 바꿔보겠습니다!
| return Integer.parseInt(input); | ||
| } | ||
|
|
||
| private void validateMoneyInput(String input) { |
There was a problem hiding this comment.
예외처리를 클래스를 만들어 따로 빼는 방식에 대해 생각해보면 좋을것 같습니다!!
| for (LottoRank lottoRank : LottoRank.values()) { | ||
| if (lottoRank != LottoRank.NONE) { | ||
| //println (X) print(X) printf(O) | ||
| System.out.printf("%s - %d개\n", lottoRank.getDescription(), result.getCountForRank(lottoRank)); |
There was a problem hiding this comment.
이 코드에서는 System.out.println(rankDescriptions.get(i) + " - " + rankCounts.get(i) + "개");
이렇게 println을 사용할 수 있겠지만
아래 printProfitRate 함수에서 System.out.printf("총 수익률은 %.1f%%입니다.\n", profitRate);
여기서 printf를 쓴 이유는 printf 는 %.1f% 와 같이 출력 형식을 제어할 수 있습니다.
또한 가독성도 높아지는 것 같아 사용하였습니다.
yohanii
left a comment
There was a problem hiding this comment.
고생하셨습니다!
stream, enum 활용법에 대해 배웠습니다👍
|
|
||
| import java.util.List; | ||
|
|
||
| public class LottoOutputView { |
There was a problem hiding this comment.
InputView, OutputView가 입출력만을 담당하면 좋을 것 같고,
InputView, OutputView가 다른 class를 의존하는 것보다, 다른 class에서 InputView, OutputView를 의존하면 더 좋을 것 같습니다!
There was a problem hiding this comment.
다른 class를 의존한다는게 현재 OutputView 코드 내의 printWinningStatistics 와 printLotto 에서 Lotto나 LottoResult class를 파라미터로 받고 함수 내에서 사용한다고 이해해도 될까요??
아쉬운점
=> 다음 미션부터는 이러한 OOP 방식에 유의하여 미리미리 할 수 있도록,,
배운점