Open
Conversation
- caculate 접두사로 변경
- 어떻게 구현할 것인지 전체적인 윤곽잡기
- 플레이어 리스트를 관리 - 정적 팩토리 메서드로 생성 - 카드 한꺼번에 뽑는 메서드 구현 - Game 안에 관련로직 수정
- Participant 클래스 상속받음 - 카드를 뽑는 메서드 오버라이딩
- 카드 1장에 대한 정보를 관리하는 Card 클래스 - 모든 카드 묶음을 관리하는 Deck 클래스
- Game 클래스를 controller 패키지로 이동
- 덱을 미리 섞어서 반환
- 카드 안전하게 반환 - 점수계산 메서드 리펙터링
- 덱 생성 - 참가자 초기화 - 현재 참가자 상태 저장
- 변경된 클래스에 맞게 코드 수정
hyunniiii
requested changes
Feb 20, 2022
hyunniiii
left a comment
There was a problem hiding this comment.
안녕하세요 현수님 ″̮
몇가지 코멘트 남겼습니다!
확인 부탁드립니다!!
| - 보유 카드 | ||
| - 승, 패 기록 | ||
| - 카드를 뽑음 | ||
| - [ ] 딜러 - Dealer |
Comment on lines
+31
to
+42
| public enum CardType { | ||
| SPADE("스페이드"), | ||
| CLOVER("클로버"), | ||
| HEART("하트"), | ||
| DIAMOND("다이아몬드"); | ||
|
|
||
| private final String name; | ||
|
|
||
| CardType(String name) { | ||
| this.name = name; | ||
| } | ||
| } |
Comment on lines
+44
to
+69
| public enum CardValue { | ||
| ACE("A", currentScore -> currentScore < 15 ? 11 : 1), | ||
| TWO("2", currentScore -> 2), | ||
| THREE("3", currentScore -> 3), | ||
| FOUR("4", currentScore -> 4), | ||
| FIVE("5", currentScore -> 5), | ||
| SIX("6", currentScore -> 6), | ||
| SEVEN("7", currentScore -> 7), | ||
| EIGHT("8", currentScore -> 8), | ||
| NINE("9", currentScore -> 9), | ||
| TEN("10", currentScore -> 10), | ||
| QUEEN("Q", currentScore -> 10), | ||
| JACK("J", currentScore -> 10), | ||
| KING("K", currentScore -> 10); | ||
|
|
||
| private final String number; | ||
| private final IntUnaryOperator intUnaryOperator; | ||
|
|
||
| CardValue(String number, IntUnaryOperator intUnaryOperator) { | ||
| this.number = number; | ||
| this.intUnaryOperator = intUnaryOperator; | ||
| } | ||
|
|
||
| public boolean isEqualCardValue(Card card){ | ||
| return this.equals(card.getCardValue()); | ||
| } |
| cards.addAll(drawCards); | ||
| } | ||
|
|
||
| public int sumCardScore() { |
| } | ||
|
|
||
| public List<Card> getCards() { | ||
| return Collections.unmodifiableList(cards); |
There was a problem hiding this comment.
unmodifiableList 보다 방어적 복사를 이용해보는건 어떨까요?
https://tecoble.techcourse.co.kr/post/2021-04-26-defensive-copy-vs-unmodifiable/
| public static Players inputPlayerName(){ | ||
| System.out.println("게임에 참여할 사람의 이름을 입력하세요. (쉼표 기준으로 분리)"); | ||
| String input = SCANNER.next(); | ||
| return Players.from(Arrays.asList(input.split(","))); |
There was a problem hiding this comment.
View에서 Players에게 의존성을 가지고 있는 것 같네요.
View와 Model은 서로를 알지 못하게 해주세요 ″̮
| .map(Player::getName) | ||
| .collect(Collectors.joining(COMMA)); | ||
|
|
||
| StringBuilder stringBuilder = new StringBuilder(); |
| } | ||
|
|
||
| public static void printAllCard(Players players, Dealer dealer){ | ||
| players.getPlayers().stream() |
There was a problem hiding this comment.
Suggested change
| players.getPlayers().stream() | |
| players.getPlayers() |
stream도 없어도 괜찮을 것 같습니다 : )
Comment on lines
+17
to
+25
| // given | ||
| Card card1 = new Card(CardType.SPADE, CardValue.KING); | ||
| Card card2 = new Card(CardType.CLOVER, CardValue.KING); | ||
|
|
||
| // when | ||
| boolean result = card1.getCardValue().isEqualCardValue(card2); | ||
|
|
||
| // then | ||
| assertThat(result).isEqualTo(true); |
There was a problem hiding this comment.
given,when,then 은 이름으로 표현해주고 주석은 지워주는건 어떨까요?
| assertThat(deckCardValue.isEqualCardValue(deckTmpCard)); | ||
| } | ||
| } | ||
| } No newline at end of file |
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.

안녕하세요 리뷰어님 !! 😀
시간이 부족해서 급하게 구현을 했는데 계속 보완해나가겠습니다..!
잘부탁드립니다!