Skip to content
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

[7주차] COW-Spring-1 학습 (taewook02) #7

Open
wants to merge 94 commits into
base: main
Choose a base branch
from

Conversation

taewook02
Copy link

racefinal

구현 기능 목록
차 이름을 쉼표 기준으로 나눠 문자열 리스트로 반환하는 메서드
차 이름을 쉼표 기준으로 나눠 문자열 리스트로 반환하는 메서드
자동차 이름을 입력받는 메서드
시도 횟수를 입력받는 메서드
0~9 사이의 난수 생성 후 반환하는 메서드
Copy link
Member

@wonjunYou wonjunYou left a comment

Choose a reason for hiding this comment

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

태욱님도 많이 느셨군요 ㅎㅎ 아주 굿입니다! run()메서드로 클래스마다 메서드 다이어트를 한게 인상적인데, 오히려 해당 run()메서드만 유지하기 위해 한 메서드가 massive해지는 결과를 일으킬 수도 있을 것 같습니다! 고생하셨습니다 ㅎ

public class Car {

private final String name;
private final int MOVE_CONDITION = 4;
Copy link
Member

Choose a reason for hiding this comment

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

static final로 선언해주세요! 해당 변수는 필드 가장 상단에 위치시켜주세요!

return carList;
}

public int getCarNumber() {
Copy link
Member

Choose a reason for hiding this comment

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

컬렉션을 사용하셨으니 carList.size() 를 반환하면 되지 않을까 싶습니다!

Map<String, Integer> raceState = raceRepository.getRaceState();
int maxValue = Collections.max(raceState.values());
List<String> maxKeys = raceState.entrySet().stream()
.filter(entry -> entry.getValue() == maxValue)
Copy link
Member

Choose a reason for hiding this comment

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

요런 필터에 사용되는 조건도 메서드로 분리하면 좋겠네요!

Comment on lines +23 to +35
public void run() {
((OutputView) outputView).outputRunTitle();
int attemptTimes = raceRepository.getAttemptTimes();
List<Car> carList = raceRepository.getCar();
IntStream.range(0, attemptTimes).forEach(i -> {
Map<String, Integer> raceState = carList.stream()
.peek(Car::move)
.collect(Collectors.toMap(Car::getName, Car::getPosition));
((OutputView) outputView).outputRunState(raceState);
raceRepository.saveRaceState(raceState);
});
}
}
Copy link
Member

Choose a reason for hiding this comment

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

해당 메서드에 대한 설명을 부탁드려도 될까요??

public class InputView implements ViewInterface {

public List<String> InputCarName() {
System.out.println("경주할 자동차 이름을 입력하세요.(이름은 쉼표(,) 기준으로 구분)");
Copy link
Member

Choose a reason for hiding this comment

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

요런 메세지는 상수로!! 처리부탁드립니다

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