-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package lotto; | ||
|
||
import lotto.domain.InputLottoNumber; | ||
import lotto.domain.LottoNumber; | ||
|
||
import java.util.List; | ||
import java.util.stream.IntStream; | ||
|
||
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(); | ||
} | ||
} | ||
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package lotto; | ||
package lotto.domain; | ||
|
||
public class BonusNumber { | ||
private final LottoNumber bonus; | ||
Comment on lines
+1
to
4
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. 다시 확인해 보니 당첨번호에 보너스 번호를 추가하고 보너스 번호가 로또 번호에 들어가 있는지 검사하는 기능을 수행했네요 |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
package lotto; | ||
package lotto.domain; | ||
|
||
import java.util.Comparator; | ||
import java.util.EnumSet; | ||
|
||
public enum LottoBonus { | ||
FIRST_PLACE(6, false, 2000000000), | ||
|
@@ -31,16 +34,9 @@ public Money getWinningMoney() { | |
} | ||
|
||
public static LottoBonus valueOf (int matchCount, boolean needBonusMatch) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. 오 확인 감사해요 수정해서 올렸습니다! |
||
for (LottoBonus bonus : values()) { | ||
if (bonus.matchCount == matchCount && bonus.needBonusMatch == needBonusMatch) { | ||
return bonus; | ||
} | ||
} | ||
for (LottoBonus bonus : values()) { | ||
if (bonus.matchCount == matchCount && !bonus.needBonusMatch) { | ||
return bonus; | ||
} | ||
} | ||
return LOSING_PLACE; | ||
return EnumSet.allOf(LottoBonus.class).stream() | ||
.filter(b -> b.matchCount == matchCount) | ||
.min(Comparator.comparing(b -> b.needBonusMatch != needBonusMatch)) | ||
.orElse(LOSING_PLACE); | ||
} | ||
} |
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.
정적 메소드를 계속 사용하면 다형성 특징을 해치고 이후 상속과 같은 개념을 사용할 때 오버라이딩이 불가능한 단점도 생기겠어요
정적 메소드를 사용하는 경우와 사용하지 않는 경우를 정확히 구분하고 객체지향적인 코드를 바라보는 것이 좋은 방향인 거 같아요