-
Notifications
You must be signed in to change notification settings - Fork 18
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
base: seongjae6751
Are you sure you want to change the base?
Conversation
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 void run() { | ||
InputHandler inputHandler = new InputHandler(); | ||
|
||
List<Player> players = inputHandler.askPlayers(); |
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.
저는 사다리게임에만 신경을 쓰다보니 플레이어를 관리해줄 생각은 못해봤네요 👍
src/main/java/Domain/Ladder.java
Outdated
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; |
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.
요구사항에 else 쓰지말고 if문으로 바로 return하는 방식으로 해보라고 써있어서 해보면 좋을 것 같아요~
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.
감사합니다~ 다시 그렇게 해보겠습니다
src/main/java/Domain/Line.java
Outdated
|
||
public class Line { | ||
private final List<Boolean> points = new ArrayList<>(); | ||
private Random random = new Random(); |
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.
final 붙이면 좋을것 같아요
@Override | ||
public String toString() { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append("|"); | ||
for (Boolean point : points) { | ||
sb.append(point ? "-----" : " "); | ||
sb.append("|"); | ||
} | ||
return sb.toString(); | ||
} |
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 Player(String name, int startPosition) { | ||
if (name.length() > 5) { | ||
throw new IllegalArgumentException("이름은 5글자 이하여야 합니다."); | ||
} | ||
this.name = name; | ||
this.startPosition = startPosition; | ||
} |
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.
이런 검증 좋은것 같아요
저도 리팩토링할때 한번 해봐야겠네용
while (true) { | ||
String playerName = inputHandler.askPlayerName(); | ||
if (playerName.equals("all")) { | ||
printAllResults(); | ||
} else { | ||
String result = getIndividualResult(playerName); | ||
System.out.println(result); | ||
} | ||
} | ||
} |
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.
앗 제가 잘못이해했나보네요
저는 그냥 대답 한번만 받도록 했는데 다른분들은 다 이렇게 하셨네요..
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 int askHeight() { | ||
System.out.println("사다리의 높이는 몇 개인가요?"); | ||
return scanner.nextInt(); |
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.
이거 개행을 안해주던데 어떻게 하셨나요??
저번에 이거 썼다가 프로그램 안돌아가서....
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.
그냥 이렇게 했더니 잘 동작해서 😅 뭐라 말씀드려야 할지 모르겠네요..ㅋㅋ
정상적으로 실행되는 것을 목표로 일단 급하게 만들었는데 한번 잘 다듬어 보겠습니다ㅠ