-
Notifications
You must be signed in to change notification settings - Fork 87
[4,5단계 - 로또 수동 구매] 최지수 미션 제출합니다 #125
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
base: jisoo78
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.
지수님, 로또 마지막 미션까지 정말 고생 많으셨어요 😊
코드를 볼 때마다 미션을 즐기시는 모습이 느껴져서 보기 좋았어요.
입력 포맷을 사용자 입장에서 편하게 구성해주신 부분도 인상 깊었고요!
조금 더 욕심을 내서, 요구사항까지 함께 챙겨주시면 지금보다 더 깔끔하고 친절한 코드가 될 수 있을 것 같아요 !
정말 수고 많으셨고, 다음 미션도 응원할게요!
화이팅입니다 💪
while (count < 0 || count > totalTicket) { | ||
System.out.println("잘못된 입력입니다 구입 금액에 맞춰 다시 작성해주세요"); | ||
count = scanner.nextInt(); | ||
} |
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.
음 정상적인 흐름에서 사용자 입력을 받을 때는 대부분 재입력을 받고
그 이외의 오류들은 예외 처리를 했습니다!
if (inputNumber < LOTTO_START_NUMBER || inputNumber > LOTTO_END_NUMBER) { | ||
throw new IllegalArgumentException("1~45 사이의 숫자만 입력 가능합니다."); | ||
} |
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.
LottoNumber에서도 동일한 검증이 일어나고 있는 것 같아요!
저는 여러 곳에서 사용되는 검증일 경우 공통적으로 가지는 것이 무엇인지 분리할 수 있는 방법이 있는지 고민해보는데요!
지수님은 어떻게 생각하시나요?
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.
동일한 검증이니 상속을 사용하는 방법을 생각해 봤는데 record는 상속을 지원하지 않는다고 하네요
그럼 공통적으로 사용되는 검증 로직을 따로 분리해서 재사용이 가능하게 만들 수 있겠네요!
|
||
assertEquals(3, autos.size(), "자동 로또 개수는 총 5장에서 수동 2장을 뺀 3장입니다."); | ||
} | ||
} |
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.
Test코드에서도 마지막 줄에는 공백 라인을 추가해주셔야 합니다!
설명이 잘되어있는 블로그 글 공유드립니다 😄
POSIX
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.
코드 작성 순서부터 이번 테스트 코드 작성 정보도 알려주셔서 감사해요!
고생 많으셨어요~ 저는 구현할 때 주어진 요구사항 중심으로 진행하는 편인데, 자수님의 코드를 보면서 사용자 경험을 더 고려하는 접근도 필요하겠다는 걸 배웠어요 👀 |
return winningMoney; | ||
} | ||
|
||
public static LottoBonus valueOf (int matchCount, boolean needBonusMatch) { |
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.
for-if로 2 depth로 들어가는 구조인데, 조건 분기를 메서드로 분리해보면 가독성이 더 좋아질 것 같아요! 🙌
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 String readLine() { | ||
System.out.println("지난 주 당첨 번호를 입력해 주세요 (예: 1,2,3,4,5,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.
입력 예시까지 함께 출력해주신 부분 좋네요! 사용자 입장에서 입력 형식을 바로 이해할 수 있어서 경험 측면에서 더 친절하게 느껴졌어요
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.
고생하셨습니다!
몇가지 사용되지 않는 객체들이 있어서 정리 한번 부탁드릴게요
package lotto.domain; | ||
|
||
public class BonusNumber { | ||
private final LottoNumber bonus; |
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.
이전 미션에서 Enum을 사용하는 과정에서 누락된 객체입니다
로또의 숫자를 맞춘 개수와 상금을 지닌 역할을 가지고 있어요
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.
다시 확인해 보니 당첨번호에 보너스 번호를 추가하고 보너스 번호가 로또 번호에 들어가 있는지 검사하는 기능을 수행했네요
BounsNumber에서 담당하던 해당 기능이 WinningNumber로 넘어가 보너스 번호에 대해서 클래스를 유지할 필요가 없어졌어요
단일 책임 원칙을 지키기 위해서 해당 클래스는 지우는 게 맞다고 생각합니다
public class LottoCounter { | ||
|
||
public static List<InputLottoNumber> generateAuto(int totalTicket, int passivityCount) { | ||
int autoLottoCount = totalTicket - passivityCount; | ||
return IntStream.range(0, autoLottoCount) | ||
.mapToObj(i -> { | ||
List<Integer> pool = LottoManage.pullOutNumbers(); | ||
LottoManage.shuffleNumbers(pool); | ||
List<LottoNumber> picked = LottoManage.pickupLottoNumbers(pool) | ||
.stream().map(LottoNumber::new).toList(); | ||
return InputLottoNumber.of(picked); | ||
}) | ||
.toList(); | ||
} | ||
} |
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.
LottoCounter 객체의 역할은 무엇인가요?
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.
전체 구매 로또 티켓에서 수동 장수를 제외한 만큼 6개 번호의 티켓을 InputLottoNumber에 반환합니다
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.
static method를 사용하면 객체지향적인 코드로부터 멀어진다고 생각하는데요!
다음 자료를 참고해보시고 제 의견에 대한 지수님의 생각을 말해주세요 🤔
https://tecoble.techcourse.co.kr/post/2020-07-16-static-method/
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.
정적 메소드를 계속 사용하면 다형성 특징을 해치고 이후 상속과 같은 개념을 사용할 때 오버라이딩이 불가능한 단점도 생기겠어요
정적 메소드를 사용하는 경우와 사용하지 않는 경우를 정확히 구분하고 객체지향적인 코드를 바라보는 것이 좋은 방향인 거 같아요
주노 안녕하세요!
이번 로또 마지막 미션 열심히 달려보겠습니다
깃이 또 문제가 생기는 바람에ㅠㅠ 이전에 step3브랜치에서 진행한 내용을 계속 못 받아와서 rebase를 통해 강제로 받아와 바뀐 파일들이 정말 많네요
추가된 내용은
(java)input - PassivityLottoInput,PassivityNumberInput lotto - LottoCounter
(test) LottoCounterTest, PassivityNumberInputTest 입니다
고민한 점
저번 피드백에 이어 깔끔한 코드와 입/출력 검증 파싱 등 카테고리별로 패키지를 나누어서 진행해 봤어요
다른 분들의 형식을 보면 정말 깔끔하게 되어 있어 지금까지 그렇게 진행하지 않은 모습을 반성했어요
인텔리제이에서 패키지를 나누면 자동으로 import를 생성해 주는 걸 처음 알았어요!!
이전 2단계 미션이 정말 어려워 오래 걸려 걱정했지만 나름 괜찮게 진행했습니다
계속 코드를 작성하다보니 메인 메서드에 책임이 많아져 나눠서 진행하는 데 고민이 많았습니다
생각해보니 로또를 구매하는 부분과 준비하는 부분을 나누어서 진행하는 게 깔끔하다고 생각해서 진행해 봤어요
궁금한 점

이 부분이 사용자 입장이나 보는 입장에서 입력하는 데 어려움이 있어 아래 사진처럼 수정해 봤어요
과제에서는 어떤 사용을 원하는지는 몰라 반복문을 통해 해결했는데 제가 한 방식이 괜찮은지 궁금해요

번호를 입력할 때마다 안내 문구가 나옵니다
ByteArrayInputStream
을 사용해 봤어요 코드 수정 없이 간편하게 입력할 수 있다는 장점이 있더라고요Scanner에서는 사용자 입력을 받아 진행되지만
ByteArrayInputStream
는 허상의 입력을 받아 테스트 코드가 실행된다? 라고 이해하고 있는데 제가 이해한 내용이 맞을까요??