-
Notifications
You must be signed in to change notification settings - Fork 75
[이현주] 연료 주입, blackjack (Step1) #38
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: hyoenju
Are you sure you want to change the base?
Conversation
- Sonata, Avante, K5
- CarTest.java - RentCarTest.java
- Player 와 Dealer에게 카드 2장을 배분 프로세스 구현
- Dealer의 이름은 "딜러"로 고정 - Dealer의 카드를 출력을 OutputView로 묶음 - 매직넘버 & 리터럴 추가
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 receive(Player player) { | ||
Gameable gameable = player.getCards(); | ||
String yesOrNo = ""; | ||
do { | ||
yesOrNo = InputView.inputYesOrNo(player.getName()); | ||
if (yesOrNo.equals("y")) { | ||
gameable.addCard(CardDeck.pop()); | ||
OutputView.printCurrentCardsState(player.getName(), player.getCards()); | ||
gameable = gameable.judge(); | ||
} | ||
if (yesOrNo.equals("n")) { | ||
gameable = new State(gameable.cards(), false); | ||
} | ||
} while (gameable.isEnd()); | ||
} |
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.
함수(또는 메서드)의 길이가 10라인을 넘어가지 않도록 구현한다.
요구사항에 맞도록 구현해보면 어떨까요?
private static final String DEALER_NAME = "딜러"; | ||
private final static int DEALER_THRESHOLD = 16; | ||
|
||
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.
players
를 일급컬렉션으로 분리해주는건 어떨까요?
책임을 조금 더 분리할 수 있을 것 같습니다.
} | ||
|
||
public boolean giveCardToDealer() { | ||
if (dealer.getCards().cards().sumScore() <= DEALER_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.getCards().cards().sumScore() <= DEALER_THRESHOLD
이 부분에 대한 책임을 넘겨주고 결과만 받아서 사용하도록 하면 어떨까요?
public class Winner { | ||
|
||
private final int BLACKJACK = 21; | ||
private final Game game; |
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.
Winner
라는 클래스가 상태값으로 Game
을 가지고 있네요.
Winner
는 우승자들
을 상태값으로 가지고 있는게 맞지 않을까요? ″̮
아니면 조금 더 적절한 이름으로 변경해주는건 어떨까요?
한번 고민해보면 좋을 것 같습니다.
|
||
public class Dealer extends Person { | ||
|
||
private final Gameable 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
도 Person
에 구현해서 중복을 줄여보는건 어떨까요?
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class OutputView { |
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://mangkyu.tistory.com/147
} | ||
|
||
public static void printGameWinOrLose(Person person, List<Integer> gameResult) { | ||
System.out.printf("%s : %d승 %d패%n", person.getName(), gameResult.get(0), gameResult.get(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.
|
||
private static final String CAR_NAME = "Avante"; | ||
private static final double DISTANCE_PER_LITER = 15; | ||
private final double distance; |
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.
상수와 변수는 개행을 통해 구분해주세요 : )
@@ -0,0 +1,27 @@ | |||
package rentcar.domain; | |||
|
|||
public abstract class Car { |
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.
각 자동차들의 distance
들도 추상클래스에 구현해주면 어떨까요?
중복을 줄일 수 있을 것 같습니다.
|
||
private static final String CAR_NAME = "K5"; | ||
private static final double DISTANCE_PER_LITER = 13; | ||
private final double distance; |
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.
여기도 상수와 변수는 개행을 통해 구분해주세요 : )
안녕하세요
연료 주입과 블랙잭 미션 구현 완료하여 과제 제출합니다.
감사합니다 :)