-
Notifications
You must be signed in to change notification settings - Fork 75
[정승연] 연료 주입, 블랙잭 (Step1) #27
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: seungyeonjeong
Are you sure you want to change the base?
Conversation
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
1. RentCompany create 메서드 구현 2. 자동차를 추가하는 addCar 메서드 구현 3. 차량별로 주입해야 할 연료를 가진 generateReport 메서드 구현 Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
1. 스페이드, 하트, 다이아몬드, 클로버 Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
1. 카드를 생성하는 테스트 코드 구현 Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
1. 초기에 카드는 섞여서 2개가 주어진다. Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
1. 카드를 제공받고 중복 삭제를 위해 2개를 지워준다. Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonyeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonyeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonyeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonyeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonyeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
1. MatchResult enum class 생성으로 매치 결과를 계산하게끔 구현 2. MatchResultBoard player와 dealer의 결과를 가지는 map 클래스 구현 3. 플레이어와 딜러의 score를 가지는 클래스 구현 4. 코드 리팩토링에 따른 메소드 추가 및 리팩토링 Co-authored-by: seungyeonyeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonyeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonyeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonyeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
1. 카드의 합을 계산하는 로직 2. card와 이름을 super를 사용해 Gamer에서 초기화 Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
1. isBlackJack 코드 위임 2. isBust 코드 위임 Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
1. 모든_게이머는_처음에_2장의_카드를_받는다 2. 플레이어의_카드_총합을_계산한다 3. ACE는_1이나_11로_계산될_수_있다 4. 플레이어는_카드를_한_장더_받을_수_있다 Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
1. 카드의_총합이_21이면_블랙잭이다 2. 카드의_총합이_21을_넘으면_버스트이다 Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
1. 플레이어가_딜러랑_카드합이_같으면_무승부다 2. 플레이어가_딜러보다_카드합이_크면_승리한다 3. 플레이어가_딜러보다_카드합이_작으면_패배한다 Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
1. 초기에_카드는_섞여서_2개가_주어진다() 2. 두_카드의_합이_16_이하일_경우_카드를_추가로_한장_받는다() 3. 두_카드의_합이_16_초과일_경우_카드를_추가로_받지_않는다() Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.com>
Co-authored-by: seungyeonjeong <crowsy@naver.com> Co-authored-by: YuYangWoo <yuyw0712@naver.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.
승연님 안녕하세요!
블랙잭 미션 잘 구현해주셨네요 :)
몇가지 코멘트를 남겼으니 확인부탁드리겠습니다!
# java-blackjack | ||
# java-blackjack | ||
|
||
# 연료주입 |
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 int FUEL_EFFICIENCY = 10; | ||
|
||
public Sonata(final double distance) { | ||
super(distance, "Sonata"); |
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 RentCompany { | ||
private static final String NEWLINE = System.getProperty("line.separator"); | ||
|
||
private final List<Car> carLists = new ArrayList<>(); |
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
라는 특정 Collection명은 제거해주는게 어떨까요? cars
로도 의미가 충분해보여요!
private final List<Car> carLists = new ArrayList<>(); | |
private final List<Car> cars = new ArrayList<>(); |
private final List<Car> carLists = new ArrayList<>(); | ||
|
||
public static RentCompany create() { | ||
return new RentCompany(); |
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.
create()
를 통해서만 생성이 가능하게하려면, 기본 생성자의 접근제한자를 private으로 선언해보면 어떨까요?
} | ||
|
||
protected double getChargeQuantity() { | ||
return getTripDistance() / getDistancePerLiter(); |
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.
getTripDistance()
메서드를 호춣하는 것보다 distance
를 바로 호출해보면 어떨까요?
|
||
private static final int BLACK_JACK_SUM_LIMIT = 21; | ||
|
||
public void start() { |
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 line을 넘어가는 것 같아요!!
아래의 요구사항을 지켜보면 어떨까요?
함수(또는 메서드)의 길이가 10라인을 넘어가지 않도록 구현한다.
함수(또는 메소드)가 한 가지 일만 하도록 최대한 작게 만들어라.
OutputView.printDealerCardSum(dealer); | ||
OutputView.printPlayerCardSum(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.
두번의 View호출을 한번으로 줄일 수 없을까요?
View호출이 Console이아닌 Network기반이라면 Network비용이 더 소모될 것 같아요!
public class Players { | ||
|
||
private final List<Player> players = new ArrayList<>(); | ||
private final String[] playerNames; |
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.
해당 필드는 생성 이후 쓰이지 않는데요! 들고있을 필요가 있을까요?
Collectors.toMap(player -> player, player -> player.getMatchResult(player, dealer), | ||
(player1, player2) -> player1, LinkedHashMap::new))); |
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가 있을 경우 mergeFunction을 수행하는 것이 아닌, 에러를 발생시켜야할 것 같은데요! 어떻게 생각하시나요?(동일한 Player가 존재할 수 있나요?)
- 아래와 같이 작성이 가능합니다!
Collectors.toMap(player -> player, player -> player.getMatchResult(player, dealer), | |
(player1, player2) -> player1, LinkedHashMap::new))); | |
Collectors.toMap(Function.identity(), player -> player.getMatchResult(player, dealer), | |
(player1, player2) -> player1, LinkedHashMap::new))); |
for(Card card : cards) { | ||
this.cards.add(card); | ||
} |
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.
addAll
을 이용해보면 어떨까요?
for(Card card : cards) { | |
this.cards.add(card); | |
} | |
this.cards.addAll(cards); |
안녕하세요 리뷰어님 😄
연료 주입, 블랙잭 미션 제출합니다.
리뷰 잘 부탁드립니다. 감사합니다!