Open
Conversation
pci2676
requested changes
Apr 14, 2025
|
|
||
| import java.util.List; | ||
|
|
||
| public class LottoGame { |
There was a problem hiding this comment.
ai를 이용해 바이브 코딩을 하셨으면 TDD를 하기 더 쉬웠을것 같은데요. 전체적인 클래스에 비해 테스트 코드가 빈약한것 같습니다. 😢
ai를 활용하는 것은 좋지만 지금 교육 프로그램에 참여하신 목적에 더 알맞게 객체지향적으로 TDD 사이클을 이용해 생각하는 연습을 하시면 더 도움이 되지 않을까 싶습니다.
지금은 너무 시간에 쫓겨 미션을 수행하기 위해 급히 바이브 코딩을 하신것 같은데 그러면 이 과정에서 얻어가시는게 너무 적지 않으실까 싶습니다.
Comment on lines
+24
to
+30
| public static LottoNumbers fromText(String text) { | ||
| List<Integer> numbers = Arrays.stream(text.split(",")) | ||
| .map(String::trim) | ||
| .map(Integer::parseInt) | ||
| .collect(Collectors.toList()); | ||
| return from(numbers); | ||
| } |
| return from(numbers); | ||
| } | ||
|
|
||
| private void validate(List<LottoNumber> numbers) { |
|
|
||
| public LottoRank lottoRank(LottoNumbers winningNumbers) { | ||
| Set<LottoNumber> winningSet = new HashSet<>(winningNumbers.numbers()); | ||
| long matchCount = numbers.stream().filter(winningSet::contains).count(); |
Comment on lines
+11
to
+15
| static { | ||
| for (int i = MIN_NUMBER; i <= MAX_NUMBER; i++) { | ||
| CACHE.put(i, new LottoNumber(i)); | ||
| } | ||
| } |
Comment on lines
+16
to
+26
| public LottoWinningRecord result() { | ||
| Map<LottoRank, Integer> rankMap = new EnumMap<>(LottoRank.class); | ||
| for (LottoRank rank : LottoRank.values()) { | ||
| rankMap.put(rank, 0); | ||
| } | ||
| purchased.forEach(ticket -> { | ||
| LottoRank rank = ticket.lottoRank(winningNumbers); | ||
| rankMap.put(rank, rankMap.get(rank) + 1); | ||
| }); | ||
| return new LottoWinningRecord(rankMap); | ||
| } |
There was a problem hiding this comment.
아무런 매개변수 없는 메서드를 이용하는 것이라면 matcher라는 클래스가 반드시 필요할까요?
Comment on lines
+15
to
+16
| private static final Map<Integer, LottoRank> MATCH_MAP = Arrays.stream(values()) | ||
| .collect(Collectors.toMap(rank -> rank.match, Function.identity())); |
| long totalPrize = rankMap.entrySet().stream() | ||
| .mapToLong(e -> e.getKey().money() * e.getValue()) | ||
| .sum(); | ||
| return totalSpent == 0 ? 0 : (double) totalPrize / totalSpent; |
Comment on lines
+35
to
+50
| @RepeatedTest(5) | ||
| @DisplayName("여러 번 실행해도 로또 번호가 매번 섞여 나온다") | ||
| void generate_returnsShuffledNumbers() { | ||
| LottoNumbers first = LottoNumberGenerator.generate(); | ||
| LottoNumbers second = LottoNumberGenerator.generate(); | ||
|
|
||
| List<Integer> firstList = first.numbers() | ||
| .stream() | ||
| .map(n -> n.getNumber()) | ||
| .collect(Collectors.toList()); | ||
| List<Integer> secondList = second.numbers() | ||
| .stream() | ||
| .map(n -> n.getNumber()) | ||
| .collect(Collectors.toList()); | ||
|
|
||
| assertThat(firstList).isNotEqualTo(secondList); |
| import java.util.List; | ||
|
|
||
| public class LottoGame { | ||
| public static void main(String[] args) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
안녕하세요.
시간이 없어서 인공지능의 힘을 빌렸,,, VIBE 코딩 어마어마하네요;;
피드백 부탁드립니다.