-
Notifications
You must be signed in to change notification settings - Fork 75
[김태준] 연료 주입, 블랙잭 - Step1 #35
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: kimtaejun97
Are you sure you want to change the base?
Conversation
- 추상클래스 Car에 존재하는 메서드 오버라이딩
- 추상클래스 Car에 존재하는 메서드 오버라이딩
- 추상클래스 Car에 존재하는 메서드 오버라이딩
1. 정상적인 입력이 들어오는 경우 2. 빈 값이 들어오는 경우, 예외 발생 3. 입력 형식에 유효하지 않은 경우, 예외 발생
1. Avante 반환 확인 2. K5 반환 확인 3. Sonata 반환 확인 4. 해당되는 이름이 없는 경우, exception 발생
1. 클래스 이름 변경 2. 메서드 변경 적절한 이름으로 변경
1. Participant 2. Player 3. Dealer
1. 카드 한 장 분배 2. 참가자의 초기 카드 분배
1. 전체 카드를 관리하는 덱 생성 2. 카드 분배 3. 참가자들에게 초기 카드 분배
- 불필요한 Wrapping 제거
1. Participant#getCardNames() 2. Hands#getCardNames()
1. 참가자 카드 출력
1. Deck > Cards 2. Game > Deck
1. 플레이어 : 21을 넘지 않는 경우, 의사를 물어봄 2. 딜러 : 16을 넘지 않는다면, 무조건 받음
승패의 경우의 수 테스트
Hands -> List<Card>로 변경
- 요구 사항 변경. - 딜러는 처음에 한장의 카드만을 보여준다.
- 플레이어가 21점이면 패배한 것으로 간주되는 버그, 21이 최대 점수가 되도록 수정.
liquidjoo
left a comment
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 Cards() { | ||
| this(Arrays.stream(Pattern.values()) | ||
| .flatMap(pattern -> | ||
| Arrays.stream(Rank.values()) | ||
| .map(rank -> new Card(pattern, rank)) | ||
| .collect(Collectors.toList()).stream()) | ||
| .collect(Collectors.toList())); | ||
| } |
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.
만약 게임이 한판만에 끝나는게 아니라 계속 게임을 다시 할 수 있다면
Card 의 객체는 계속 생성될 것 같아요
객체의 생성을 어떻게 줄여볼 수 있을까요?
| public Card draw() { | ||
| checkDeckIsEmpty(); | ||
| Collections.shuffle(cards); | ||
| return cards.get(SELECTED_CARD); | ||
| } |
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 Card draw() { | ||
| final Card card = cards.draw(); | ||
| cards.remove(card); | ||
| return card; | ||
| } |
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.
해당 메서드의 테스트를 어떻게 해볼 수 있을까요?
| import java.util.List; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| public class Hands { |
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.
카드를 관리하기 위한 객체 👍
| private static final int ACE_VALUE_1 = 1; | ||
| private static final int ACE_VALUE_11 = 11; | ||
|
|
||
| private final List<Card> 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.
Cards 라는 일급컬렉션이 있는데 활용해보면 좋지 않을까요?
| private static final String PLAYER_LOSE = "패"; | ||
| private static final String DEALER_WIN_OR_LOSE_FORMAT = "%d승 %d패"; | ||
|
|
||
| public Map<String, String> getWinOrLose(final Participant dealer, final List<Participant> players) { |
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.
Map 을 일급컬렉션으로 활용해보면 어떨까요?
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class CardTest { |
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.
매 요청마다 카드 객체가 생성되는 것을 최소화 해보고 이를 테스트 코드로 나타내보면 좋을 것 같아요 :)
| @DisplayName("카드 한장을 뽑는다.") | ||
| @Test | ||
| void GivenNothing_When카드_뽑기_Then카드() { | ||
| // When | ||
| final Card card = sut.draw(); | ||
|
|
||
| // Then | ||
| assertThat(card).isNotNull(); | ||
| } |
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.
내가 어떤 카드를 뽑았는지 테스트를 해보려면 어떻게 해보는 것이 좋을까요?
| final Car sonata = new Sonata(200D); | ||
| assertThat(sonata.getChargeQuantity()).isEqualTo(20D); | ||
| } | ||
| } 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.
파일 마지막에 엔터(개행문자)를 넣어주세요!!
이유는 리뷰를 진행할 때 깃허브에서 경고메시지를 지우기 위함입니다.
좀 더 알고 싶으시면 재미삼아 아래의 링크를 보시는 것도 추천 드립니다.
https://minz.dev/19
Intellij 를 사용하실 경우엔
Preferences -> Editor -> General -> Ensure line feed at file end on save 를 체크해주시면
파일 저장 시 마지막에 개행문자를 자동으로 넣어줍니다!
| private static final int ACE_VALUE_11 = 11; | ||
|
|
||
| private final List<Card> cards; | ||
| private Score score; |
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.
Score 라는 객체와 결합을 갖는 것도 좋지만
Hands 와 Score 두 객체의 메시지 전달로 표현을 해보아도 좋을 것 같아요
안녕하세요 성주님!! 😀
이번 미션인 연료 주입, 블랙잭 구현 해 보았습니다.
네이밍에 신경을 쓰면서 작성을 해보았는데 어떨지 모르겠네요!
불변객체가 되도록 신경쓰면서 작성하였습니다.
그러나 Deck 같은 경우는 불변으로 만들지 않았는데요, Deck을 불변으로 만들게 되면
Application단에서 카드를 뽑고, Deck에서 카드를 제거하는 부분이 밖으로 나가야해 좋아보이지 않았습니다.
이 부분에 대한 리뷰어님의 의견이 궁금합니다!!
먼저 리뷰 감사합니다!! 잘부탁드립니다. 🙇♂️