-
Notifications
You must be signed in to change notification settings - Fork 383
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단계 - 블랙잭] 기론(김규철) 미션 제출합니다. #226
Merged
Merged
Changes from 37 commits
Commits
Show all changes
77 commits
Select commit
Hold shift + click to select a range
5aa725d
test: 테스트 작성
Juhyung990122 67807ba
feat: 추상클래스 Car 생성
Juhyung990122 ee1a9fe
feat: 종류별 자동차 도메인 구현
Juhyung990122 b28bbe9
feat: 연료 계산 및 주입 기능 구현
Juhyung990122 7161dc5
docs: 기능 요구 사항 작성
Juhyung990122 2ffc15c
feat: 참가자 이름 입력 기능 구현
Juhyung990122 6592e9d
feat: 유저 도메인 생성
Juhyung990122 6f32dec
feat: 카드, 카드팩토리 도메인 생성 및 캐싱
Juhyung990122 ec380dd
feat: Player,Dealer 도메인 생성 및 Dto변환 구현
Juhyung990122 65ea3ec
feat: 카드 넘버에 이름 추가
Juhyung990122 807fbf7
feat: CardDto 변환로직 구현 및 UserDto 리턴타입 수정
Juhyung990122 898beda
feat: 딜러와 참가자 카드 출력 기능 구현
Juhyung990122 bd394f5
feat: player 생성 및 카드 분배 기능 구현
Juhyung990122 f7f5050
feat: 딜러 카드 공개 로직 추가
Juhyung990122 66f520b
feat: 한장의 카드 받는 기능 구현
Juhyung990122 ea9fa87
refactor: 뷰의 책임을 컨트롤러로 이전
Juhyung990122 ac35b89
test: 카드분배기능 테스트 작성
Juhyung990122 05827d6
feat: 카드 추가 기능 구현
Juhyung990122 8750ed4
feat: 카드 추가 질의 기능 구현
Juhyung990122 0542747
feat: 플레이어 소지 카드 출력 구현
Juhyung990122 002889e
chore: 안내메세지 추가
Juhyung990122 bf87a2e
feat: 카드 리스트를 일급컬렉션으로 변환
Juhyung990122 b39dc59
feat: 카드 점수 계산 기능 구현
Juhyung990122 e4e796a
refactor: 접근제어자 수정
Juhyung990122 a64fdc1
test: Cards 테스트 추가
Juhyung990122 3557611
feat: 딜러 카드 추가 조건 구현
Juhyung990122 f58dd8f
feat: 최종 결과 출력 기능 구현
Juhyung990122 07a3b75
refactor: 미사용 코드 삭제
Juhyung990122 8c7ee51
feat: 최종 승패 출력 기능 구현
Juhyung990122 e76aa89
feat: 결과 DTO 생성
Juhyung990122 8159fe2
feat: 승패 판단 로직 수정
Juhyung990122 afaf8e5
test: 승패 판정 테스트 작성
Juhyung990122 314393a
feat: 입력 검증 로직 구현
Juhyung990122 b3c44d5
refactor: Controller 구조개선 및 Dealer 도메인 수정
Juhyung990122 ef0935d
feat: 카드 추가 로직 입력 형식 검증
Juhyung990122 0ac0ff6
refactor: 승패 판단 로직 수정
Juhyung990122 8cae334
refactor: 패키지 분리 및 코드포멧팅
Juhyung990122 2393038
refactor: 변수에 final 적용 및 매서드에 람다식 적용
Gyuchool dbc2aa8
refactor: public 상수 private으로 변경 및 매직넘버 제거
Gyuchool 6e80286
refactor: 처음 카드들 초기화 하는 매서드 네이밍 수정
Gyuchool da8abdd
refactor: cards 도메인에 맞는 자료구조 변경 및 부생성자 생성
Gyuchool 3ed5fe1
refactor: players일급 컬렉션 추가
Gyuchool c6a1387
refactor: controller가 하는 일 줄이도록 수정
Gyuchool b42b547
refactor: 방어적 복사 적용
Gyuchool 3f646fc
test: 유저 입력한 만큼 참가자 생성되는지 테스트
Gyuchool f7af5bb
refactor: convention에 맞게 수정
Gyuchool 5cb9d5a
refactor: ace찾는 로직 get함수 제거
Gyuchool d100e02
refactor: indent 2 제거
Gyuchool 56ad261
refactor: CARD_CACHE 자료구조 Queue로 변경
Gyuchool d8586d9
refactor: 덱에서 캐싱 제거
Gyuchool ba13f67
refactor: 정적 팩토리 메서드 네이밍 수정
Gyuchool d03126b
refactor: ace찾는 매서드 및 네이밍 수정
Gyuchool 6ea48e5
fix: 게임 규칙에 맞게 21이 넘으면 카드를 더 받을지 안 물어보도록 수정
Gyuchool 2d334d3
refactor: dealer도 cardFactory를 통해서 카드 받도록 수정
Gyuchool 2e80acc
refactor: y와 n 매직 넘버 제거
Gyuchool 83b7f5b
refactor: dealer카드를 더 받는지 확인하는 매서드 네이밍 수정
Gyuchool 5d622a5
refactor: get함수 제거
Gyuchool 87a951e
test: 통계 테스트 추가
Gyuchool 4022d7d
refactor: 디렉토리 이름 변경 및 카드에 캐싱 적용
Gyuchool 79540cd
refactor: drawOneCard를 통한 initCards매서드 수정
Gyuchool 1268c7b
refactor: 매서드 분리 및 매서드 메서드 네이밍 수정
Gyuchool 08781bb
refactor: bustLine검증 책임 cards로 이전
Gyuchool 3b9a5e5
refactor: 우승자 결정 로직 PlayerResult로 옮김
Gyuchool 51f79ec
fix: 블랙잭 규칙에 맞게 수정
Gyuchool 178d91b
refactor: hit일때 boolean값을 반환하도록 수정
Gyuchool 2eb9509
refactor: 네이밍 수정
Gyuchool e8c5cc1
refactor: dealer Cards를 받아 생성하도록 수정
Gyuchool dc38f44
test: UserTest 추가
Gyuchool 2d4c447
refactor: 딜러 승패무 횟수 얻는 로직 수정
Gyuchool 63786b2
refactor: 승패 로직 수정
Gyuchool 860426a
refactor: Card를 VO로 만든다.
Gyuchool 10ec7f0
refactor: 무승부일때 로직 수정 및 코드 포멧팅
Gyuchool bee8566
refactor: dealer lose할 경우의 수 추가
Gyuchool ebe0b74
Revert "refactor: dealer lose할 경우의 수 추가"
Gyuchool 3e8852b
refactor: result Test 추가 및 dealer lose 경우의 수 추가
Gyuchool 91dbac5
refactor: 접근 지정자 private으로 수정
Gyuchool 2a85843
refactor: add 반환 타입 boolean으로 변경
Gyuchool File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package BlackJack; | ||
|
||
import BlackJack.controller.BlackjackController; | ||
|
||
public class Application { | ||
public static void main(String[] args) { | ||
BlackjackController blackjackController = new BlackjackController(); | ||
blackjackController.run(); | ||
|
||
} | ||
|
||
} |
88 changes: 88 additions & 0 deletions
88
src/main/java/BlackJack/controller/BlackjackController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package BlackJack.controller; | ||
|
||
import BlackJack.domain.Card.CardFactory; | ||
import BlackJack.domain.Result; | ||
import BlackJack.domain.User.Dealer; | ||
import BlackJack.domain.User.Player; | ||
import BlackJack.dto.DealerResultDto; | ||
import BlackJack.dto.PlayerResultDto; | ||
import BlackJack.dto.UserDto; | ||
import BlackJack.view.InputView; | ||
import BlackJack.view.OutputView; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class BlackjackController { | ||
|
||
public void run() { | ||
List<String> inputPlayerNames = InputView.inputPlayerNames(); | ||
Dealer dealer = new Dealer(CardFactory.drawTwoCards()); | ||
List<Player> players = joinGame(inputPlayerNames); | ||
OutputView.printDrawMessage(inputPlayerNames); | ||
OutputView.printTotalUserCards(convertToListDto(dealer, players)); | ||
|
||
OutputView.printTotalResult(playGame(dealer, players)); | ||
|
||
List<PlayerResultDto> resultDtos = calculatePlayerResult(dealer, players); | ||
DealerResultDto dealerDto = calculateDealerResult(dealer, players); | ||
OutputView.printFinalResult(resultDtos, dealerDto); | ||
} | ||
|
||
private DealerResultDto calculateDealerResult(Dealer dealer, List<Player> players) { | ||
int dealerLoseCount = dealer.getDealerLoseCount(); | ||
int dealerDrawCount = dealer.getDealerDrawCount(); | ||
DealerResultDto dealerDto = DealerResultDto.from( | ||
dealer.getName(), | ||
dealerLoseCount, | ||
dealerDrawCount, | ||
players.size() - (dealerLoseCount + dealerDrawCount)); | ||
return dealerDto; | ||
} | ||
|
||
private List<PlayerResultDto> calculatePlayerResult(Dealer dealer, List<Player> players) { | ||
List<PlayerResultDto> resultPlayerDtos = new ArrayList<>(); | ||
for (Player player : players) { | ||
Result compare = dealer.compare(player); | ||
resultPlayerDtos.add(PlayerResultDto.from(player.getName(), compare)); | ||
} | ||
return resultPlayerDtos; | ||
} | ||
|
||
private List<UserDto> playGame(Dealer dealer, List<Player> players) { | ||
for (Player player : players) { | ||
addCard(player); | ||
} | ||
while (dealer.checkScore()) { | ||
jnsorn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
OutputView.printAddDealerCard(); | ||
dealer.addCard(); | ||
} | ||
return convertToListDto(dealer, players); | ||
|
||
} | ||
|
||
public List<Player> joinGame(List<String> inputPlayerNames) { | ||
List<Player> players = new ArrayList<>(); | ||
for (String name : inputPlayerNames) { | ||
players.add(new Player(name, CardFactory.drawTwoCards())); | ||
jnsorn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
return players; | ||
} | ||
|
||
private List<UserDto> convertToListDto(Dealer dealer, List<Player> players) { | ||
List<UserDto> userDtos = new ArrayList<>(); | ||
userDtos.add(UserDto.from(dealer)); | ||
for (Player player : players) { | ||
userDtos.add(UserDto.from(player)); | ||
} | ||
return userDtos; | ||
} | ||
|
||
public void addCard(Player player) { | ||
while (InputView.askOneMoreCard(UserDto.from(player))) { | ||
player.addCard(); | ||
OutputView.printPlayerCard(UserDto.from(player)); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package BlackJack.domain.Card; | ||
|
||
public class Card { | ||
|
||
private Shape shape; | ||
private Number number; | ||
|
||
public Card(Shape shape, Number number) { | ||
this.shape = shape; | ||
this.number = number; | ||
} | ||
|
||
public Shape getShape() { | ||
return shape; | ||
} | ||
|
||
public Number getNumber() { | ||
return number; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package BlackJack.domain.Card; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class CardFactory { | ||
|
||
static List<Card> CARD_CACHE = new ArrayList<>(); | ||
|
||
static { | ||
for (Shape shape : Shape.values()) { | ||
for (Number number : Number.values()) { | ||
CARD_CACHE.add(new Card(shape, number)); | ||
} | ||
} | ||
Collections.shuffle(CARD_CACHE); | ||
|
||
} | ||
jnsorn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public static Cards drawTwoCards() { | ||
List<Card> cards = CARD_CACHE.subList(0, 2); | ||
CARD_CACHE = new ArrayList<>(CARD_CACHE.subList(2, CARD_CACHE.size())); | ||
return new Cards(cards); | ||
} | ||
|
||
public static Card drawOneCard() { | ||
Card card = CARD_CACHE.get(0); | ||
CARD_CACHE = new ArrayList<>(CARD_CACHE.subList(1, CARD_CACHE.size())); | ||
return card; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package BlackJack.domain.Card; | ||
|
||
import java.util.List; | ||
|
||
public class Cards { | ||
public static final int BUST_LINE = 21; | ||
public static final int EXTRA_SCORE = 10; | ||
private List<Card> deck; | ||
jnsorn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public Cards(List<Card> deck) { | ||
this.deck = deck; | ||
} | ||
|
||
public List<Card> getDeck() { | ||
return deck; | ||
} | ||
|
||
public void add(Card card) { | ||
deck.add(card); | ||
} | ||
|
||
public int calculateScore() { | ||
int score = deck.stream() | ||
.mapToInt(card -> card.getNumber().getValue()) | ||
.sum(); | ||
|
||
return addAceScore(score); | ||
} | ||
|
||
private int addAceScore(int score) { | ||
long countAce = deck.stream() | ||
.filter(card -> card.getNumber().getDenomination().equals("A")) | ||
.count(); | ||
|
||
for (int i = 0; i < countAce; i++) { | ||
if (score + EXTRA_SCORE <= BUST_LINE) { | ||
score += EXTRA_SCORE; | ||
} | ||
} | ||
return score; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package BlackJack.domain.Card; | ||
|
||
public enum Number { | ||
ACE("A", 1), | ||
TWO("2", 2), | ||
THREE("3", 3), | ||
FOUR("4", 4), | ||
FIVE("5", 5), | ||
SIX("6", 6), | ||
SEVEN("7", 7), | ||
EIGHT("8", 8), | ||
NINE("9", 9), | ||
TEN("10", 10), | ||
JACK("J", 10), | ||
QUEEN("Q", 10), | ||
KING("K", 10); | ||
|
||
private String denomination; | ||
private int value; | ||
|
||
Number(String denomination, int value) { | ||
this.denomination = denomination; | ||
this.value = value; | ||
} | ||
|
||
public String getDenomination() { | ||
return denomination; | ||
} | ||
|
||
public int getValue() { | ||
return value; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package BlackJack.domain.Card; | ||
|
||
public enum Shape { | ||
HEART("하트"), | ||
DIAMOND("다이아몬드"), | ||
SPADE("스페이드"), | ||
CLOVER("클로버"); | ||
|
||
private String shapeName; | ||
|
||
Shape(String shapeName) { | ||
this.shapeName = shapeName; | ||
} | ||
|
||
public String getShapeName() { | ||
return shapeName; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package BlackJack.domain; | ||
|
||
public enum Result { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 결과를 구하는 로직이 여기 저기 흩어져 있어요. 결과와 관련된 로직을 Result에서 관리해볼까요? |
||
WIN("승"), | ||
DRAW("무"), | ||
LOSE("패"); | ||
|
||
private final String value; | ||
|
||
Result(String value) { | ||
this.value = value; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package BlackJack.domain.User; | ||
|
||
import BlackJack.domain.Card.CardFactory; | ||
import BlackJack.domain.Card.Cards; | ||
import BlackJack.domain.Result; | ||
|
||
public class Dealer extends User { | ||
|
||
private static final int DEALER_ADD_CARD_LIMIT = 16; | ||
|
||
private int dealerLoseCount = 0; | ||
private int dealerDrawCount = 0; | ||
|
||
public Dealer(Cards cards) { | ||
super("딜러", cards); | ||
} | ||
|
||
@Override | ||
public void addCard() { | ||
cards.add(CardFactory.drawOneCard()); | ||
} | ||
|
||
public boolean checkScore() { | ||
return cards.calculateScore() <= DEALER_ADD_CARD_LIMIT; | ||
} | ||
|
||
public Result compare(Player player) { | ||
if (player.getScore() > 21 || (this.getScore() > player.getScore() && this.getScore() <= 21)) { | ||
jnsorn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return Result.LOSE; | ||
} | ||
if (this.getScore() > 21 || this.getScore() < player.getScore() && player.getScore() <= 21) { | ||
dealerLoseCount++; | ||
return Result.WIN; | ||
} | ||
dealerDrawCount++; | ||
return Result.DRAW; | ||
} | ||
|
||
public int getDealerLoseCount() { | ||
return dealerLoseCount; | ||
} | ||
|
||
public int getDealerDrawCount() { | ||
return dealerDrawCount; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package BlackJack.domain.User; | ||
|
||
import BlackJack.domain.Card.CardFactory; | ||
import BlackJack.domain.Card.Cards; | ||
|
||
public class Player extends User { | ||
public Player(String name, Cards cards) { | ||
super(name, cards); | ||
} | ||
|
||
@Override | ||
public void addCard() { | ||
cards.add(CardFactory.drawOneCard()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package BlackJack.domain.User; | ||
|
||
import BlackJack.domain.Card.Cards; | ||
|
||
public abstract class User { | ||
jnsorn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
protected String name; | ||
protected Cards cards; | ||
|
||
public User(String name, Cards cards) { | ||
this.name = name; | ||
this.cards = cards; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public Cards getCards() { | ||
return cards; | ||
} | ||
|
||
abstract public void addCard(); | ||
|
||
public int getScore() { | ||
return cards.calculateScore(); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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의 역할은 무엇인가요? 지금 BlackjackController는 하는 일이 너무 많은 것 같아요. 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.
처음에 controller에서는
Application
에서InputView
들을 통해 받아온 값들을 처리해주고dto
형식으로 반환해서Application
에서OuputView
를 반환하는 형태로 하려고 했습니다.controller는 그저 정보들을 주고 받는 매개 역할만 하도록요!
그런데 이번 미션을 진행하면서
player
에게 매번 카드를 더 받을것인지 물어보고(InputView) 그에 대한 반응(outputView)을 하는 과정에서 controller외부에서 받고 처리하려니 너무 어렵더라고요.. (아마 구조부터 잘못된것이지..)그래서 우선 controller안에 view를 넣어서 진행해 보았습니다😢
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의 역할은
정보들을 주고 받는 매개 역할
이군요! 하지만 지금 controller는 dealer도 생성하고, players도 생성하고, 결과도 생성하는 등 다양한 일을 하고 있는 것 같아요. (결과를 구하는 로직은 다른 곳으로 옮겨졌네요👍🏼) 이런 행위들을 controller에서 하는 게 맞을까요?추가로 기론이 고민하신 부분(사용자로부터 입력을 받아 카드를 더 받는 로직)은 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.
Player
의addCard()
매서드안에 조건이 추가되야한다고 생각됩니다.그런데 지금 구조에서는 while문의 조건이 변경될 것 같네요..?
음....그렇다면
player.addCard()
매서드를 while문의 조건으로 넣는건 괜찮은 시도일까요?시도 후
player.hit()
매서드를 while문의 조건에 넣고,player.hit()
매서드 내부에서 bust인지 체크하려고 했는데 이렇게 되면 버스트가 되고도 한번 더 카드를 받을 것인지 묻는 메시지가 출력되더군요. 😢그래서 일단은
player.isBust()
로 앞에서 확인을 시키는 매서드를 while문에 넣었는데 더 좋은 방법이 있을것 같은데 잘 모르겠네요😭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.
Player
에게 카드를 받을 수 있는 상태인지 물어볼 수 있을 것 같네요 😃