Open
Conversation
Make InputView receive inputs. getWinnersName() in Winners get winners name by stream
PandaHun
requested changes
May 2, 2021
Member
PandaHun
left a comment
There was a problem hiding this comment.
- build와 gradle폴더에
gitignore추가 부탁드려요. - 공통적으로 코드에 마지막 줄이 없는 경우가 있습니다
이 또한 컨벤션이니 맞춰주세요 - 이번 주차의 실습 요구사항을 맞춰주세요
재리뷰 요청드립니다.
| nameCheck = Validator.validateName(carNames); | ||
| ErrorCatcher.catchNameError(nameCheck); | ||
|
|
||
| if (nameCheck[0] == 0 && nameCheck[1] == 0) { |
| cycle = inputView.inputCycle(); | ||
|
|
||
| nameCheck = Validator.validateName(carNames); | ||
| ErrorCatcher.catchNameError(nameCheck); |
Member
There was a problem hiding this comment.
전형적인 절차지향코드 형태입니다.
객체지향을 살려서 코드를 구현해 주세요.
선언과 할당이 분리될 필요가 없습니다
|
|
||
| public String[] inputCarNames(){ | ||
| System.out.println("경주할 자동차 이름을 입력하세요.(이름은 쉼표(,) 기준으로 구분)"); | ||
| return SCANNER.nextLine().split(","); |
Member
There was a problem hiding this comment.
매직 넘버란 코드 안에 작성된 구체적인 숫자 혹은 문자열을 말합니다. 그리고 매직 넘버의 단점은 아래와 같습니다.
- 의미를 이해하기 어렵다.
- 복수의 장소에서 사용된다면 변경하기 힘들다.
그런 매직 넘버는 의미를 나타낼 수 있는 상수로 치환하여 코드의 가독성을 높여 보는 것은 어떨까요?
| .collect(Collectors.toList()); | ||
| OutputView.printResultTitle(); | ||
|
|
||
| for (int i = 0; i < cycle; i++) { |
| } | ||
|
|
||
| public List<Car> moveCar() { | ||
| for (Car car : cars) { |
| List<String> winnerName = new ArrayList<>(); | ||
|
|
||
| winnerName = cars.stream() | ||
| .filter(x -> x.getPosition() == maxPosition) |
| if (nameErrors[1] == 1) { | ||
| System.out.println("[ERROR] 이름의 길이가 부적절합니다."); | ||
| } | ||
| } |
|
|
||
| // index 0에 이름 중복 검사 결과 | ||
| // index 1에 이름 길이 검사 결과 | ||
| validationResult[0] = isNameOnly(carNames); |
Member
There was a problem hiding this comment.
주석이 필요한 코드는 충분한 의미를 담지 못했다고 생각됩니다
| validationResult[1] = 1; | ||
| break; | ||
| } | ||
| } |
| return 1; | ||
| } | ||
| nameCount.put(carNames[i], "이것은 존재한."); | ||
| } |
array for car name validation has been changed to primitive type variables. and method for car name validation has been changed stream form. I madd main method length short.
I replaced magic number, SCANNER to not magic number, scanner.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.