Conversation
| if (name.length() > 5) { | ||
| throw new IllegalArgumentException(); | ||
| } |
There was a problem hiding this comment.
5 와 같이 무언가 의미있는 수들은 상수로 바꿔서 작성하시는 것을 권장드립니다
private static final int CAR_MOVE_STANDARD = 5;
There was a problem hiding this comment.
피드백 감사합니다. 아직은 상수 분리까지 익숙하지 않아서 노력해보겠습니다!
| throw new IllegalArgumentException(); | ||
| } | ||
|
|
||
| if (name.chars().anyMatch(Character::isWhitespace)) { |
There was a problem hiding this comment.
오 이런 식으로도 공백을 체크할 수 있군요..!
스트림을 활용하시는 것 좋습니다
There was a problem hiding this comment.
공백 검사할 방법을 찾아보다가 이렇게 써봤습니다. 그래도 자신감이 생기네요
| List<Car> cars = makeCars(); | ||
| int tryCount = getTryCount(); | ||
|
|
||
| System.out.println(); |
There was a problem hiding this comment.
System.out.print('\n') 으로 하는 것이 성능 상 이득을 볼 수 있습니다!
그 이유도 함께 조사해보시면 좋을 것 같아요
There was a problem hiding this comment.
제가 백슬래시 쓰는법을 몰라서 ㅠㅠ 조사하면서 배우겠습니다.
| try { | ||
| count = Integer.parseInt(input); | ||
| } catch (NumberFormatException e) { | ||
| throw new IllegalArgumentException(); | ||
| } |
There was a problem hiding this comment.
Integer.parseInt() 를 활용해서 숫자인지 체크하는 것 좋습니다
There was a problem hiding this comment.
제가 잘 몰라서 숫자인지 체크하는 이유가 뭔가요? 잘못된 입력을 처리하기 위해서인가요?
| for (Car car : cars) { | ||
| if (car.getPosition() > max) { | ||
| max = car.getPosition(); | ||
| } | ||
| } |
There was a problem hiding this comment.
이 코드의 depth 를 다음과 같이 바꿔서 한 단계 줄일 수도 있습니다
| for (Car car : cars) { | |
| if (car.getPosition() > max) { | |
| max = car.getPosition(); | |
| } | |
| } | |
| for (Car car : cars) { | |
| max = Math.max(max, car.getPosition()); | |
| } |
No description provided.