-
Notifications
You must be signed in to change notification settings - Fork 13
[0주차] 6기 객체지향 코드 연습(최세린) #7
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
base: main
Are you sure you want to change the base?
Conversation
0702Yoon
left a comment
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.
특정 부분에서 잘짰다고 생각하는 부분도 존재하고 노력하신 게 보여서 좋습니다!
하지만 전체적으로 "매직넘버" 처리가 안되어있고, controller의 역할이 좀 많아보여요. 한번 분리해보시죠
| if (trimmed.isEmpty()) { | ||
| throw new IllegalArgumentException("자동차 이름이 공백"); | ||
| } | ||
|
|
||
| if (trimmed.length() > 5) { | ||
| throw new IllegalArgumentException("이름 오류"); | ||
| } |
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.
View에서 검사까지 하도록 일부로 노리신 건가요? 책임 분리 해볼까요?
또한 현재 예외 메시지만을 보고는 정확한 도메인 이해가 잘 되지 않아요.
| //경주차 이름 입력 | ||
| public String[] getMemberNames() { | ||
| System.out.println("경주할 자동차 이름을 입력하세요.(이름은 쉼표(,) 기준으로 구분)"); | ||
| List<String> lst = List.of(scanner.nextLine().split(",")); |
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.
split을 통해 배열로도 받을 수 있는 데 List로 받으신 이유가 특별히 있나요?
|
|
||
| public class Controller { | ||
| private final View view; | ||
| private final List<Member> members = new ArrayList<>(); |
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.
현재는 무조건 하나의 게임만 존재하기 떄문에 이렇게 구현해도 괜찮지만, 한번 이 Controller가 상태를 갖지 않도록 해볼까요?
| private String name; | ||
| private int go; |
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 printProgress(List<Member> members) { | ||
| for (Member m : members) { | ||
| System.out.println(m.getName() + " : " + "-".repeat(m.getGo())); |
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.
member에서 get을 사용하지 않고 값을 보여주도록 해볼까요?
get을 쓰면 안좋은 이유가 뭐가 있을까요?
No description provided.