-
Notifications
You must be signed in to change notification settings - Fork 48
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
[로또 미션] 이현수 미션 제출합니다 #43
base: 20hyeonsulee
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
스트림을 잘 쓰시니 코드가 전체적으로 깔끔하고 읽기 편했던 것 같아요.
고생 많으셨습니다!
OutputView outputView = new OutputView(); | ||
LottoGame lottoGame = new LottoGame(inputView, outputView); | ||
lottoGame.play(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
혹시 main과 별도의 실행 클래스를 분리하는 이유가 있나요?
잘 몰라서 여쭤봅니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
나름 관심사를 분리한다고 분리했던것 같습니다!
private static Lotto generateLottoNumber() { | ||
Set<LottoNumber> lottoNumbers = IntStream.generate(() -> ThreadLocalRandom.current().nextInt(1, 46)) | ||
.distinct() | ||
.limit(6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
처음부터 limit를 걸어버리면 예외처리를 생략해도 되는군요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
어멋.. 생각해보니 제가 예외처리를 꼼꼼하게 못한것같네요.. ㅠ
src/main/java/view/OutputView.java
Outdated
} | ||
|
||
private void printResult(Rank rank, Integer count) { | ||
String bonus = rank.containsBonus()? ", 보너스 볼 일치": " "; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
삼항연산자를 쓰지 말라는 조건이 있었습니다!
그래도 확실히 삼항연산자를 쓰는게 더 간결해지고 보기 편하네요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
으악! 수정하겠습니다
|
||
public void printMyLottos(List<Lotto> manual, List<Lotto> auto) { | ||
System.out.println(String.format("수동으로 %d장, 자동으로 %d개를 구매했습니다.", manual.size(), auto.size())); | ||
manual.stream().forEach(System.out::println); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오.. 그러고 보니 println을 스트림으로 써 볼 생각을 못했네요.
src/main/java/model/LottoGame.java
Outdated
List<Lotto> autoLottos = RandomLottoGenerator.generateLottoNumbers(autoCount); | ||
outputView.printMyLottos(manualLottos, autoLottos); | ||
Lotto winningLotto = inputView.readWinningLotto(); | ||
Integer bonusNumber = inputView.readBonusNumber(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
입력한 보너스 번호가 이미 뽑힌 번호 중에 있지 않은지에 대한 검증이 필요하다고 생각합니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오.. 맞네요 수정했습니다!
import java.util.Arrays; | ||
|
||
public enum Rank { | ||
_LAST(0, 0, false), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
등수 외의 상수도 있으니 예외 대신 쓸수 있고 명확하네요!
이번주차는 stream을 최대한 많이 사용해보려고 했습니다.
확실히 stream을 사용하는게 가독성측면에서 더 좋다는 느낌을 받았습니다.
추가로 원시값과 컬렉션을 포장하여 사용하면 얻을 수 있는 장점이 많다는 것을 느꼈습니다.(예외처리와 같은 부분)
리뷰 잘부탁드립니다!