-
Notifications
You must be signed in to change notification settings - Fork 75
[한승진] 연료 주입, 블랙잭 (Step 1) #30
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: hsj-96
Are you sure you want to change the base?
Conversation
- caculate 접두사로 변경
- 어떻게 구현할 것인지 전체적인 윤곽잡기
- 플레이어 리스트를 관리 - 정적 팩토리 메서드로 생성 - 카드 한꺼번에 뽑는 메서드 구현 - Game 안에 관련로직 수정
- Participant 클래스 상속받음 - 카드를 뽑는 메서드 오버라이딩
- 카드 1장에 대한 정보를 관리하는 Card 클래스 - 모든 카드 묶음을 관리하는 Deck 클래스
- Game 클래스를 controller 패키지로 이동
- 덱을 미리 섞어서 반환
- 카드 안전하게 반환 - 점수계산 메서드 리펙터링
- 덱 생성 - 참가자 초기화 - 현재 참가자 상태 저장
- 변경된 클래스에 맞게 코드 수정
- CardType enum에 이름 설정 - Card 정보를 반환하는 toString() 메서드 구현
- 처음 2장씩뽑는경우, 1장씩 뽑는경우 나눠서 메서드 구현 - 정보를 반환하는 메서드 구현 - 승점을 계산하는 메서드 구현
- 사용자 입력 메서드 구현
- 출력 하는 메서드 구현
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.
안녕하세요 승진님!
몇 가지 코멘트를 남겼습니다.
블랙잭 요구사항과 코멘트를 확인 부탁드립니다.
|
||
@Override | ||
public void drawCardContinue(Deck deck) { | ||
System.out.println(name + "는 한장의 카드를 더 받겠습니까?(예는 y, 아니오는 n)"); |
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의 책임 아닐까요?
|
||
@Override | ||
public void drawCardMultiple(Deck deck, int number) { | ||
cards.addCards(deck.drawMultiple(number)); |
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.
21점이상 되면 카드를 더 받을 수 없는 조건이 추가 되어야 할 것 같습니다.
} | ||
|
||
@Override | ||
public void drawCardContinue(Deck deck) { |
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 void drawCardContinue(Deck deck) { | |
public boolean drawCardContinue(Deck deck) { |
이렇게 수정해 컨트롤러에 메시지를 던지는 방식으로 수정해보는 것은 어떨까요?
그리고 21점이 넘으면 카드를 받을 수 없는 조건이 빠져있습니다.
if (cards.sumCardScore() > 17) { | ||
return; | ||
} | ||
System.out.println("딜러는 16이하라 한장의 카드를 더 받았습니다."); |
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.
앞선 미션에서 학습한 MVC패턴을 지켜보는 것은 어떨까요?
return new Deck(types, values); | ||
} | ||
|
||
public List<Card> drawMultiple(int num) { |
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.
매번 카드를 생성해서 리턴하는 것보다 덱에서 카드를 뽑아 전달하는 방식으로 수정해 보는 것은 어떨까요?
실제 블랙잭 게임에서 52장의 Card를 덱으로 만들어 딜러와 플레이어에게 전달하는 방식으로 게임을 운영하는 것을 생각해 보면 구현에 도움이 될 것 같습니다.
return cards.sumCardScore(); | ||
} | ||
|
||
public abstract void drawCardMultiple(Deck deck, int number); |
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 abstract void drawCardMultiple(Deck deck, int number); | |
public abstract void drawCardMultiple(Deck deck); |
메서드 이름에서 행위가 표현됩니다. 굳이 카드 숫자를 받아 처리할 필요가 없을 것 같습니다.
} | ||
|
||
public final String holdingInfo() { | ||
return name + COLON + cards.toString(); |
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.
앞서 학습한 MVC패턴을 적용해보면 어떨까요?
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class ParticipantCards { |
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.
참가자의 카드 점수에 따른 상태값을 가지도록 수정해보는 것은 어떨까요?
if (InputView.isContinue()) { | ||
cards.addCards(deck.drawMultiple(1)); | ||
System.out.println(holdingInfo()); | ||
drawCardContinue(deck); |
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.
연료 주입, 블랙잭 (Step1) 미션 제출합니다.