Skip to content

Conversation

@hyuunnn
Copy link

@hyuunnn hyuunnn commented Nov 15, 2022

이번 챌린지는 functional한 기능들을 사용하여 구현해봤습니다.

확실히 코드가 길어지지 않고 한 눈에 보이네요.

시간 날 때마다 업데이트 해보겠습니다.

테스트 코드도 작성해보겠습니다 ㅎㅎ..

@hyuunnn hyuunnn self-assigned this Nov 15, 2022
Copy link
Contributor

@shkisme shkisme left a comment

Choose a reason for hiding this comment

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

리뷰가 조금 늦었습니다! 🙇‍♀️ stream 을 아주 잘 쓰시네요 ㅎㅎ

private void printStatus() {
carList.forEach(car ->
System.out.printf("%s : %s\n", car.getName(),
PROGRESS_BAR.repeat(car.getPosition())));
Copy link
Contributor

Choose a reason for hiding this comment

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

👍👍👍 for 문으로 돌리는 것보다 훨씬 간결합니다

public static final int RANDOM_MIN_NUMBER = 4;
public static final String SEPARATOR = ",";
public static final String PROGRESS_BAR = "-";
public static final Scanner SCANNER = new Scanner(System.in);
Copy link
Contributor

Choose a reason for hiding this comment

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

의미가 있는 상수, 자주쓰는 상수, Scanner 들을 Util 클래스로 분리하신 점 좋습니다!


private void input() {
System.out.println("경주할 자동차 이름을 입력하세요.(이름은 쉼표(,) 기준으로 구분)");
while (inputCarNames() == false)
Copy link
Contributor

Choose a reason for hiding this comment

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

inputCarNames 메서드가 boolean 값을 반환하고 있는데, 어떤 의미인지 명확하진 않은 것 같습니다. Enum으로 표현하는 것은 어떨까요?

ex)

while (inputCarNames() == INVALID)
;

Copy link
Author

Choose a reason for hiding this comment

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

Enum으로 수정하겠습니다!

.collect(Collectors.joining(String.format("%s ", SEPARATOR))));
}

public void run() {
Copy link
Contributor

Choose a reason for hiding this comment

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

run 메서드를 클래스 가장 밑에 두신 이유가 있나요? 코드 가독성 면에서는 위에 두는 것도 괜찮을 것 같아서요!

Copy link
Author

Choose a reason for hiding this comment

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

파이썬 코드를 저렇게 짜다 보니까 습관이 되었네요..

int maxPosition = carList.stream()
.map(Car::getPosition)
.reduce(Integer::max)
.orElse(-1);
Copy link
Contributor

Choose a reason for hiding this comment

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

👍👍👍👍

private int count = 0;

private int randomize() {
Random r = new Random();
Copy link
Contributor

Choose a reason for hiding this comment

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

RandomUtil 클래스에 두거나, GamePlayer 필드에 두는 것은 어떤가요?

@hyuunnn
Copy link
Author

hyuunnn commented Nov 18, 2022

@shkisme 수정 완료하였습니다 :)

Copy link
Contributor

@shkisme shkisme left a comment

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.

3 participants