Skip to content

Conversation

hscom96
Copy link

@hscom96 hscom96 commented Feb 17, 2022

안녕하세요 리뷰어님 !! 😀

시간이 부족해서 급하게 구현을 했는데 계속 보완해나가겠습니다..!
잘부탁드립니다!

hyeonsu and others added 30 commits February 11, 2022 16:07
- caculate 접두사로 변경
- 어떻게 구현할 것인지 전체적인 윤곽잡기
- 플레이어 리스트를 관리
- 정적 팩토리 메서드로 생성
- 카드 한꺼번에 뽑는 메서드 구현
- Game 안에 관련로직 수정
- Participant 클래스 상속받음
- 카드를 뽑는 메서드 오버라이딩
- 카드 1장에 대한 정보를 관리하는 Card 클래스
- 모든 카드 묶음을 관리하는 Deck 클래스
- Game 클래스를 controller 패키지로 이동
- 덱을 미리 섞어서 반환
- 카드 안전하게 반환
- 점수계산 메서드 리펙터링
- 덱 생성
- 참가자 초기화
- 현재 참가자 상태 저장
- 변경된 클래스에 맞게 코드 수정
Copy link

@hyunniiii hyunniiii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

안녕하세요 현수님 ″̮
몇가지 코멘트 남겼습니다!
확인 부탁드립니다!!

- 보유 카드
- 승, 패 기록
- 카드를 뽑음
- [ ] 딜러 - Dealer

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

다 완료 된 부분은 표시해주면 어떨까요?

Comment on lines +31 to +42
public enum CardType {
SPADE("스페이드"),
CLOVER("클로버"),
HEART("하트"),
DIAMOND("다이아몬드");

private final String name;

CardType(String name) {
this.name = name;
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

따로 클래스로 분리해주는건 어떨까요?

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());
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

따로 클래스로 분리해주는건 어떨까요?

cards.addAll(drawCards);
}

public int sumCardScore() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분도 테스트할 수 있지 않을까요?

}

public List<Card> getCards() {
return Collections.unmodifiableList(cards);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(",")));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

View에서 Players에게 의존성을 가지고 있는 것 같네요.
ViewModel은 서로를 알지 못하게 해주세요 ″̮

.map(Player::getName)
.collect(Collectors.joining(COMMA));

StringBuilder stringBuilder = new StringBuilder();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StringBuilder 를 사용하지 않아도 괜찮을 것 같아요 ″̮
image

}

public static void printAllCard(Players players, Dealer dealer){
players.getPlayers().stream()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given,when,then 은 이름으로 표현해주고 주석은 지워주는건 어떨까요?

assertThat(deckCardValue.isEqualCardValue(deckTmpCard));
}
}
} No newline at end of file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

마지막줄은 뉴라인을 추가해주세요 ″̮

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants