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

[사다리 미션] 김성재 미션 제출합니다. #5

Open
wants to merge 6 commits into
base: seongjae6751
Choose a base branch
from

Conversation

seongjae6751
Copy link

@seongjae6751 seongjae6751 commented Jul 20, 2024

정상적으로 실행되는 것을 목표로 일단 급하게 만들었는데 한번 잘 다듬어 보겠습니다ㅠ

Copy link

@dradnats1012 dradnats1012 left a comment

Choose a reason for hiding this comment

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

고생하셨습니당

public void run() {
InputHandler inputHandler = new InputHandler();

List<Player> players = inputHandler.askPlayers();

Choose a reason for hiding this comment

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

저는 사다리게임에만 신경을 쓰다보니 플레이어를 관리해줄 생각은 못해봤네요 👍

Comment on lines 22 to 30
for (Line line : line) {
if (currentPosition > 0 && line.getPoints().get(currentPosition - 1)) {
currentPosition--;
} else if (currentPosition < line.getPoints().size() && line.getPoints().get(currentPosition)) {
currentPosition++;
}
}

return currentPosition;

Choose a reason for hiding this comment

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

요구사항에 else 쓰지말고 if문으로 바로 return하는 방식으로 해보라고 써있어서 해보면 좋을 것 같아요~

Copy link
Author

Choose a reason for hiding this comment

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

감사합니다~ 다시 그렇게 해보겠습니다


public class Line {
private final List<Boolean> points = new ArrayList<>();
private Random random = new Random();

Choose a reason for hiding this comment

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

final 붙이면 좋을것 같아요

Comment on lines +27 to +36
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("|");
for (Boolean point : points) {
sb.append(point ? "-----" : " ");
sb.append("|");
}
return sb.toString();
}

Choose a reason for hiding this comment

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

이 방법은 생각 못해봤네요 👍

Comment on lines +7 to +13
public Player(String name, int startPosition) {
if (name.length() > 5) {
throw new IllegalArgumentException("이름은 5글자 이하여야 합니다.");
}
this.name = name;
this.startPosition = startPosition;
}

Choose a reason for hiding this comment

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

이런 검증 좋은것 같아요
저도 리팩토링할때 한번 해봐야겠네용

Comment on lines +40 to +49
while (true) {
String playerName = inputHandler.askPlayerName();
if (playerName.equals("all")) {
printAllResults();
} else {
String result = getIndividualResult(playerName);
System.out.println(result);
}
}
}

Choose a reason for hiding this comment

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

앗 제가 잘못이해했나보네요
저는 그냥 대답 한번만 받도록 했는데 다른분들은 다 이렇게 하셨네요..

Copy link
Author

Choose a reason for hiding this comment

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

예시에서 실행결과 보니까 결과를 보고 싶은 사람 여러번 할 수 있게 해놓으셨더라구요!


public int askHeight() {
System.out.println("사다리의 높이는 몇 개인가요?");
return scanner.nextInt();

Choose a reason for hiding this comment

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

이거 개행을 안해주던데 어떻게 하셨나요??
저번에 이거 썼다가 프로그램 안돌아가서....

Copy link
Author

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