Skip to content

[사다리타기 - FP, OOP] 3단계 - 사다리(게임 실행) #1441

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

Merged
merged 8 commits into from
Jun 4, 2022

Conversation

logantect
Copy link

안녕하세요!
[사다리타기 - FP, OOP] 3단계 - 사다리(게임 실행) 구현 완료하여 PR 드립니다!
2단계 피드백 내용도 작업하였습니다!

이번에도 리뷰 잘 부탁드릴게요!! :)
감사합니다!

logantect and others added 8 commits May 25, 2022 17:15
step2 피드백 반영
- 매직 넘버, 매직 리터럴 상수로 분리
- Ladder -> Lines 일급 컬렉션으로 변경
- 사다리 게임 발판 전략 패턴 적용
- 출력 View StringBuilder 정적으로 선언해 재활용 하도록 구현
- 사다리 높인 경계값 테스트 및 파라미터 테스트 적용
- 플레이어명 비어있는 이름 예외 처리
사디리 포인트 이동(왼쪽, 오른쪽, 멈춤) 기능 구현.
- 현재 포인트를 가지는 Point객체 추가
- 현재 이동 방향을 알 수 있는 Direction Enum 객체 추가.
사다리 특정 위치에서 시작해서 포인트 이동하는 기능 구현.
- 현재 위치 값과 포인트를 가지는 Position 객체 추가
사다리 가로 라인 위치 이동 기능 구현.
- Line 객체 추가 및 move 메서드 구현
실행결과는 쉼표(,)로 구분한다
- 실행결과를 가지는 Result 객체생성
- 실행결과들을 가지는 Results 일급컬렉션 객체 생성
포인트 값으로 실행결과 찾기
- 플레이어 이름으로 플레이어 시작 포인트 찾기 메서드 추가
- 실행결과 포인트로 실행결과 찾기 메서드 추가
사다리 실행 결과를 출력
- 사다리 실행 결과를 출력
- 개인별 이름을 입력하면 개인별 결과를 출력.
"all"을 입력하면 전체 참여자의 실행 결과를 출력.
- all 입력 구분하여 결과 출력 분기
Copy link
Contributor

@javajigi javajigi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

전체적인 객체 설계, 클린코드, 테스트 코드 구현 잘 했네요. 👍
생성자로 하나만 추가하고 있는데요.
타입이 다른 생성자도 추가하고 그 효과를 느껴보면 좋겠네요.
다음 단계 진행할 때 피드백 반영해 보세요.

@@ -3,61 +3,54 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Random;

public class Line {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

일급 콜렉션 역할에 집중하도록 구현 👍

@@ -23,6 +25,13 @@ public int count() {
return players.size();
}

public int point(String playerName) {
return point(new Player(playerName));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

convention 위반
메서드 사이에 blank line을 추가하는 것이 convention

@@ -4,13 +4,29 @@

public class Player {

public static final int MAX_NAME_LENGTH = 5;
private final String name;

public Player(String name) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name 문자열 포장 👍

public Direction move() {
if (current) {
return Direction.RIGHT;
} else if (left) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

early return을 하고 있으므로 굳이 else는 없어도 되지 않을까?

public static final String JOINING_DELIMITER = " ";
private final List<Result> results;

public Results(List<Result> results) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

생성자로 List외에 String과 같은 다른 type을 받는 생성자를 추가해 보는 것은 어떨까?

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

public class Players {

public static final String DELIMITER = ",";
public static final String JOINING_DELIMITER = " ";
private final List<Player> players;

public Players(List<Player> players) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

생성자로 List외에 String과 같은 다른 type을 받는 생성자를 추가해 보는 것은 어떨까?

@javajigi javajigi merged commit 0ce461f into next-step:jeongjaeeom Jun 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants