-
Notifications
You must be signed in to change notification settings - Fork 75
[김현수] 연료 주입, blackjack (Step1) #42
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: hscom96
Are you sure you want to change the base?
Conversation
- caculate 접두사로 변경
- 어떻게 구현할 것인지 전체적인 윤곽잡기
- 플레이어 리스트를 관리 - 정적 팩토리 메서드로 생성 - 카드 한꺼번에 뽑는 메서드 구현 - Game 안에 관련로직 수정
- Participant 클래스 상속받음 - 카드를 뽑는 메서드 오버라이딩
- 카드 1장에 대한 정보를 관리하는 Card 클래스 - 모든 카드 묶음을 관리하는 Deck 클래스
- Game 클래스를 controller 패키지로 이동
- 덱을 미리 섞어서 반환
- 카드 안전하게 반환 - 점수계산 메서드 리펙터링
- 덱 생성 - 참가자 초기화 - 현재 참가자 상태 저장
- 변경된 클래스에 맞게 코드 수정
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.
안녕하세요 현수님 ″̮
몇가지 코멘트 남겼습니다!
확인 부탁드립니다!!
- 보유 카드 | ||
- 승, 패 기록 | ||
- 카드를 뽑음 | ||
- [ ] 딜러 - Dealer |
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.
다 완료 된 부분은 표시해주면 어떨까요?
public enum CardType { | ||
SPADE("스페이드"), | ||
CLOVER("클로버"), | ||
HEART("하트"), | ||
DIAMOND("다이아몬드"); | ||
|
||
private final String name; | ||
|
||
CardType(String name) { | ||
this.name = name; | ||
} | ||
} |
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.
따로 클래스로 분리해주는건 어떨까요?
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()); | ||
} |
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.
따로 클래스로 분리해주는건 어떨까요?
cards.addAll(drawCards); | ||
} | ||
|
||
public int sumCardScore() { |
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.
이 부분도 테스트할 수 있지 않을까요?
} | ||
|
||
public List<Card> getCards() { | ||
return Collections.unmodifiableList(cards); |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
View
에서 Players
에게 의존성을 가지고 있는 것 같네요.
View
와 Model
은 서로를 알지 못하게 해주세요 ″̮
.map(Player::getName) | ||
.collect(Collectors.joining(COMMA)); | ||
|
||
StringBuilder stringBuilder = new StringBuilder(); |
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.
} | ||
|
||
public static void printAllCard(Players players, Dealer dealer){ | ||
players.getPlayers().stream() |
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.
players.getPlayers().stream() | |
players.getPlayers() |
stream
도 없어도 괜찮을 것 같습니다 : )
// 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.
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 |
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.
마지막줄은 뉴라인을 추가해주세요 ″̮
안녕하세요 리뷰어님 !! 😀
시간이 부족해서 급하게 구현을 했는데 계속 보완해나가겠습니다..!
잘부탁드립니다!