-
Notifications
You must be signed in to change notification settings - Fork 75
[박찬우] 연료주입, 블랙잭 구현 #28
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: chanuuuuu
Are you sure you want to change the base?
Conversation
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
- Avante - `Avante` String Type 이름을 가져야한다. - `15km/리터`의 연비 가져야한다. - 거리 가져야한다. - 거리는 `0` 이상 정수이어야한다. - - 주입해야할 연료량을 구할 수 있다. Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
- Avante - `Avante` String Type 이름을 가져야한다. - `15km/리터`의 연비 가져야한다. - 거리 가져야한다. - 거리는 `0` 이상 정수이어야한다. - - 주입해야할 연료량을 구할 수 있다. Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
- Avante - `Avante` String Type 이름을 가져야한다. - `15km/리터`의 연비 가져야한다. - 거리 가져야한다. - 거리는 `0` 이상 정수이어야한다. - - 주입해야할 연료량을 구할 수 있다. Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
- K5 - `K5` String Type 이름을 가져야한다. - `13km/리터`의 연비 가져야한다. - 거리 가져야한다. - 거리는 `0` 이상 정수이어야한다. - 주입해야할 연료량을 구할 수 있다. Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
- K5 - `K5` String Type 이름을 가져야한다. - `13km/리터`의 연비 가져야한다. - 거리 가져야한다. - 거리는 `0` 이상 정수이어야한다. - 주입해야할 연료량을 구할 수 있다. Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
- K5 - `K5` String Type 이름을 가져야한다. - `13km/리터`의 연비 가져야한다. - 거리 가져야한다. - 거리는 `0` 이상 정수이어야한다. - 주입해야할 연료량을 구할 수 있다. Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
변경된 클래스 - Avante - K5 Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
- 게임 진행시 최초로 GameCard를 셔플할 수 있다. - User별로 초기 카드를 나눠준다. - GameCard에서 Card를 두 장 뽑기 - User에게 Card 전달하기 Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
- 게임 진행시 최초로 GameCard를 셔플할 수 있다. - User별로 초기 카드를 나눠준다. - GameCard에서 Card를 두 장 뽑기 - User에게 Card 전달하기 Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
- 게임 진행시 최초로 GameCard를 셔플할 수 있다. - User별로 초기 카드를 나눠준다. - GameCard에서 Card를 두 장 뽑기 - User에게 Card 전달하기 Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
- BlackJack - 게임 로직 수행 - GameUser를 가지고 있다. - GameCard를 가지고 있다. - 게임 진행시 최초로 GameCard를 셔플할 수 있다. - User별로 초기 카드를 나눠준다. - GameCard에서 Card를 두 장 뽑기 - User에게 Card 전달하기 - Dealer는 총 score가 16이하일 경우, 1장의 카드를 추가로 받는다. - User별로 턴을 진행할 수 있게 한다. - GameCard에서 Card를 한 장 뽑기 - User에게 Card 전달하기 - Player는 총 score가 21이하일 경우, 1장의 카드를 추가로 받을 수 있다. Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
- BlackJack - 게임 로직 수행 - GameUser를 가지고 있다. - GameCard를 가지고 있다. - 게임 진행시 최초로 GameCard를 셔플할 수 있다. - User별로 초기 카드를 나눠준다. - GameCard에서 Card를 두 장 뽑기 - User에게 Card 전달하기 - Dealer는 총 score가 16이하일 경우, 1장의 카드를 추가로 받는다. - User별로 턴을 진행할 수 있게 한다. - GameCard에서 Card를 한 장 뽑기 - User에게 Card 전달하기 - Player는 총 score가 21이하일 경우, 1장의 카드를 추가로 받을 수 있다. Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
- UserStats - User별 승/패에 대한 정보 - GameUser를 인자로 받아 User별, 승/패 정보를 계산한다. Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
- UserStats - User별 승/패에 대한 정보 - GameUser를 인자로 받아 User별, 승/패 정보를 계산한다. Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
- UserStats - User별 승/패에 대한 정보 - GameUser를 인자로 받아 User별, 승/패 정보를 계산한다. Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
- UserStats - User별 승/패에 대한 정보 - GameUser를 인자로 받아 User별, 승/패 정보를 계산한다. Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
- UserStats - User별 승/패에 대한 정보 - GameUser를 인자로 받아 User별, 승/패 정보를 계산한다. - User별 Deck의 score를 출력하기 위한 String을 반환할 수 있다. convertTotalScore() - User별 최종 승/패를 출력하기 위한 String을 반환할 수 있다. convertTotalResult() - User별 Deck의 score가 21을 초과할 경우, 승/패를 계산할 수 있다. - Dealer의 score가 21을 초과할 경우, Player가 승리한다. - Dealer의 score가 21을 초과하지 않고, Player의 score가 21을 초과하는 경우, Dealer가 승리한다. Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
Co-authored-by: hochan222 <hochan049@gmail.com> Co-authored-by: chanuuuuu <dn0208@gmail.com>
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.
안녕하세요 찬우님!
몇가지 코멘트 남겼습니다.
확인 부탁드립니다 😄
- Intellij 제안에 따라 수정
- CardType의 Suit 사용 - CardNumber의 TrumpNumber 사용
- Deck의 추가 메서드 삭제 - Deck 메서드 순서 변경
- Card의 score 계산 로직 Card로 이동
- draw 여부 로직 이동
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 class Game { | ||
|
||
private static Game game = null; |
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.
이 부분이 필요한 이유는 무엇일까요?
없어도 되지 않을까요? ″̮
또한 Controller는 상태를 가지고 있지 않아도 될 것 같습니다 ″̮
@@ -0,0 +1,18 @@ | |||
package blackJack.domain; | |||
|
|||
public class CardType { |
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.
CardType
객체를 생성하는 대신 Suit
를 바로 사용해보는건 어떨까요?
} | ||
|
||
public boolean isCardDraw() { | ||
return deck.getScore() <= ADDITIONAL_CARD_DRAW_SCORE_THRESHOLD; |
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
가 deck
에게 너의 점수를 알려줘
하기보다는 deck
이 스스로 판단하도록 하는게 자율적인 행동이 아닐까요?
또한 메서드 이름이 getScore
에서 변경된다면 Dealer
와 Player
, Deck
총 세번의 변경이 일어나야합니다.
이렇게 여러번 변경되면 SOLID 원칙을 위반하게 되겠네요 ″̮
return new Deck(deck); | ||
} | ||
|
||
public String convertDeckFormat() { |
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.
toString
을 이용해보면 어떨까요?
public class GameUser { | ||
|
||
private final Dealer dealer; | ||
private final List<Player> 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.
List<Player> players
를 일급컬렉션으로 만들어보는건 어떨까요?
} | ||
|
||
public List<Player> getPlayers() { | ||
return 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.
이렇게 players를 바로 넘겨주면 getPlayers().add()
가 가능하게 됩니다.
방어적 복사를 이용해보는건 어떨까요?
https://tecoble.techcourse.co.kr/post/2021-04-26-defensive-copy-vs-unmodifiable/
ACE("A"), TWO("2"), THREE("3"), FOUR("4"), FIVE("5"), SIX("6"), SEVEN("7"), | ||
EIGHT("8"), NINE("9"), TEN("10"), JACK("J"), QUEEN("Q"), KING("K"); | ||
|
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.
ACE("A"), TWO("2"), THREE("3"), FOUR("4"), FIVE("5"), SIX("6"), SEVEN("7"), | |
EIGHT("8"), NINE("9"), TEN("10"), JACK("J"), QUEEN("Q"), KING("K"); | |
ACE("A"), | |
TWO("2"), | |
THREE("3"), | |
FOUR("4"), | |
FIVE("5"), | |
SIX("6"), | |
SEVEN("7"), | |
EIGHT("8"), | |
NINE("9"), | |
TEN("10"), | |
JACK("J"), | |
QUEEN("Q"), | |
KING("K"); |
길어지더라도 enum 정렬은 이렇게 해주는게 어떨까요?
} | ||
|
||
public String convertStatus() { | ||
return String.format("%s 카드: %s", userName.getName(), deck.convertDeckFormat()); |
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
의 책임이지 않을까요?
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class UserStats { |
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
와 관련되어 보여요.
view
와 관련된 부분은 view
로 옮겨주는건 어떨까요?
if (player.getScore() > Deck.MATCH_SCORE) { | ||
return true; | ||
} | ||
return player.getScore() < gameUser.getDealer().getScore(); |
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.
디미터 법칙을 위반하고 있네요.
위반하지 않도록 수정해주세요 ″̮
No description provided.