Skip to content
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

[1단계 - 블랙잭 구현] 다니(이다은) 미션 제출합니다. #139

Merged
merged 69 commits into from
Mar 10, 2021

Conversation

da-nyee
Copy link

@da-nyee da-nyee commented Mar 4, 2021

안녕하세요 미립! 다니입니다 🙌

블랙잭 구현이 생각보다 더 어려워서 제출이 약간 늦었습니다...!
데드라인에 맞춰서 제출은 미리하지만, 틈틈이 더 수정하겠습니다!
미션을 진행하면서 궁금했던 점이랑 학습 로그는 추후에 작성해서 코멘트 남기겠습니다 👀

바쁘신 와중에 귀중한 시간 내주셔서 감사합니다 ✨

- 카드 분배여부를 확인하는 추상 메소드 선언 및 구현
@da-nyee
Copy link
Author

da-nyee commented Mar 8, 2021

안녕하세요 미립! 다니입니다 🙌

피드백 남겨주신대로 리팩토링 진행했습니다!
DM 질문에 빠르게 답변해주셔서 다시 한번 감사드립니다 🙇‍♀️

리팩토링을 하다가 궁금한 점이 생겼는데요!

현재는 게임 결과를 구하는 로직이 Player 기준으로 Dealer도 판단해서 결정하게 되어있습니다.
근데, 일반적인 게임은 보통 딜러가 진행하니까 Dealer 기준으로 Player의 결과를 판단하는 게 맞지 않나? 라는 의문이 들었습니다.
리뷰어님의 생각이 궁금해요! 전자의 방식보다 후자의 방식이 더 자연스러울까요?? 아니면 지금처럼 둬도 괜찮을까요?!

이번에도 귀한 시간 내주셔서 감사합니다! 코드 리뷰 잘 부탁드립니다~! 🙏

@da-nyee
Copy link
Author

da-nyee commented Mar 8, 2021

📚 다니의 학습 로그

[Java] HashMap vs LinkedHashMap - 2

내용

  • HashMap과 LinkedHashMap 둘 다 Map의 특징을 지닌다는 공통점이 있음
  • HashMap은 데이터의 삽입 순서를 보장하지 않는 반면, LinkedHashMap은 삽입 순서를 보장한다는 차이점이 있음
  • HashMap은 AbstractMap 클래스를 구현하는 한편, LinkedHashMap은 HashMap을 구현한다는 차이점도 있음

링크

[Java] 무한 스트림 - 3

내용

  • 무한 스트림은 iterate() 또는 generate()를 이용해서 생성할 수 있음
  • 무한 스트림을 언바운드(unbounded) 스트림이라고 표현함
  • 무한 스트림을 사용할 때는 limit()과 같은 쇼트서킷(short circuit) 연산이 필요함

링크

Copy link

@seok-2-o seok-2-o left a comment

Choose a reason for hiding this comment

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

피드백 반영하고 새로운 객체 도출하느라 고생 많으셨어요.
해당 객체를 조금 더 객체답게 고민해볼 수 있는 코멘트 남겨 놓았습니다.
고민해보고 제 의견에 동의한다면 리팩토링 진행해주시고,
동의하지 않는다면 다시 PR 주세요. 바로 머지 할 수 있도록 하겠습니다.

어려운점이나 궁금한점은 편하게 DM 주세요.

Comment on lines 19 to 26
public void setUpPlayers(List<String> names) {
this.players = new Players(names);
}

public void setUpUsers() {
this.users.add(this.dealer);
this.users.addAll(this.players.getPlayers());
}
Copy link

Choose a reason for hiding this comment

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

둘은 생성자를 통해서 생성해주면 어떤 장점이 있을까요?

참고로 이번과정에서 setter 사용은 금지(?) 되어 있습니다.

public class BlackjackGame {
private final Deck deck = new Deck();
private final Dealer dealer = new Dealer();
private final List<User> users = new ArrayList<>();
Copy link

Choose a reason for hiding this comment

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

딜러랑 플레이어즈를 구지 같이 가지고 있어야 할지 의문이에요

import java.util.Collections;
import java.util.List;

public class BlackjackGame {
Copy link

Choose a reason for hiding this comment

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

해당 객체를 통해 블랙잭 게임을 완전히 캡슐화 해보는건 어떤가요?
컨트롤러 입장에서는 블랙잭 룰을 몰라도 게임이 진행 될 수 있도록 수정 할 수 있으면 좋을 것 같아요.

제가 컨트롤러를 만들고 다니가 게임 코어 엔진을 만든다고 생각해볼게요.

제가 구현하는 부분은 아래와 같습니다.

  1. 게임을 생성한다.
  2. 게임이 종료되었는지 확인한다.
  3. 게임이 종료되었지 않았다면
    3.1. 현재 플레이어와 카드를 출력한다.
    3.2. 클라이언트에서 전달받은 응답을 게임에게 다시 전달한다.
pobi카드: 2하트, 8스페이드
pobi는 한장의 카드를 더 받겠습니까?
  1. 3번으로 돌아간다.
  2. 게임이 종료되었다면 게임의 결과를 출력한다.

Copy link
Author

Choose a reason for hiding this comment

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

캡슐화가 생각보다 감이 잘 안 잡히네요.. 😥
게임 객체를 수정하면서 나름대로 컨트롤러 캡슐화를 진행한 거 같은데, 확신이 안 들어서 질문 드립니다!
BlackjackController가 리팩토링한 클래스인데, 제대로 캡슐화를 한 것인가요??
혹시 아직 부족한 점이 있다면 말씀해주세요!! 바로 반영해보겠습니다! 🙇‍♀️

Choose a reason for hiding this comment

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

출력을 제외하고 getter 가 사용되는 부분이 하나도 남지 않아야 캡슐화가 잘 진행되었다고 불 수 있을 것 같아요.
위에 제가 설명한걸 코드로 풀면 아래와 같아요(컨트롤러에서 수행되는 로직)

Game game = new Game(players):
OutputView.print(game);
while(game.isEnd()) {
    Player player = game.getCurrentPlayer():
    String res = InputView.ask(player) => 'player.name' 은 한장의 카드를 더 받겠습니까?
    game.next(res) ;
}

OutputView.print(game.getResult());

Comment on lines 14 to 29
public Result decideResultByBust(Dealer dealer) {
if (dealer.isBust() && !this.isBust()) {
return Result.WIN;
}
if (!dealer.isBust() && this.isBust()) {
return Result.LOSE;
}
return Result.STANDOFF;
}

public Result decideResultByCompare(Dealer dealer) {
return Arrays.stream(Result.values())
.filter(value -> value.getCompareResult() == this.cards.compareTo(dealer.cards))
.findFirst()
.orElseThrow(IllegalAccessError::new);
}
Copy link

Choose a reason for hiding this comment

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

둘을 분리할 필요가 있었을까요?

@da-nyee
Copy link
Author

da-nyee commented Mar 9, 2021

안녕하세요 미립! 다니입니다 🙌

추가로 코멘트 남겨주신 것들 반영해봤는데 확인 부탁드립니다!
피드백에서 궁금한 부분은 👀 이모지로 표시해뒀습니다. 이 부분도 확인해주시면 감사하겠습니다! 🙏

Copy link

@seok-2-o seok-2-o left a comment

Choose a reason for hiding this comment

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

피드백 반영 잘해주셨네요 👍

질문하신 내용에 추가 코멘트 남겨놓았습니다. 해당부분 확인 부탁드려요.

@da-nyee
Copy link
Author

da-nyee commented Mar 10, 2021

안녕하세요 미립!

게임 객체 캡슐화 답변해주신 것 참고해서 다시 리팩토링 진행해봤습니다!
혹시 더 수정할 부분이 있다면 편하게 말씀해주세요!
코드 리뷰 항상 감사합니다 🥰

Copy link

@seok-2-o seok-2-o left a comment

Choose a reason for hiding this comment

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

피드백 반영 빠르게 잘 해주셨어요 💯
소소한 질문하나 더 남겨놓았는데 다음 미션 진행하면서 함께 고민해보면 좋을 것 같아요.

Comment on lines +24 to +30
public void drawCardToPlayer(Player player) {
player.draw(this.deck);
}

public boolean isPlayerHit(Player player) {
return player.isHit();
}

Choose a reason for hiding this comment

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

게임은 Player 가지고 있는데 외부에서 주입 받을 필요가 있을까요?

@seok-2-o seok-2-o merged commit f9a1135 into woowacourse:da-nyee Mar 10, 2021
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.

None yet

2 participants