-
Notifications
You must be signed in to change notification settings - Fork 5
[java-onboarding-week-1] roki.kim(김경록) 과제 제출합니다. #1
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: roki/java-onboarding-week-1
Are you sure you want to change the base?
[java-onboarding-week-1] roki.kim(김경록) 과제 제출합니다. #1
Conversation
yohanii
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.
고생 많으셨습니다! 👍
- 작은 함수 단위 분리
- if else문 줄이기 + 중간 탈출
- 네이밍
부분 신경 써주시면, 가독성이 더 좋아질 거 같아요!
| if(pobi.size() != 2 || crong.size() != 2) { | ||
| return -1; | ||
| } | ||
| if(pobi.get(0) <= 1 || crong.get(0) <= 1 || pobi.get(1) >= 400 || crong.get(1) >= 400) { | ||
| return -1; | ||
| } | ||
| if(pobi.get(1) <= pobi.get(0) || pobi.get(1) - pobi.get(0) != 1 || crong.get(1) <= crong.get(0) || crong.get(1) - crong.get(0) != 1) { | ||
| return -1; | ||
| } |
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.
검증과정을 따로 함수로 빼서, 모아서 보면 더 좋을 것 같아요!
| if(pobiSum > crongSum) answer = 1; | ||
| else if(pobiSum < crongSum) answer = 2; | ||
| else answer = 0; | ||
|
|
||
| return answer; |
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.
answer에 값을 넣어서 마지막에 리턴하는 것보다,
중간에 탈출할 수 있게하면 더 좋을 것 같습니다!
그리고 마지막 else는 제거할 수 있을 거 같아요
| return sum; | ||
| } | ||
|
|
||
| public static Integer plusMultiplyComp(Integer LR) { |
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.
Comp가 무엇을 뜻하는지 잘 모르겠어서, 풀어서 쓰는 것도 좋을 것 같아요
LR보다 더 이해하기 좋은 네이밍이 있을 것 같아요! 저는 page라고 했어요
| } | ||
|
|
||
| public static Integer multiplyAll(List<Integer> allDigit) { | ||
| int sum = 1; |
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.
sum보다 더 좋은 네이밍이 있을 거 같습니다
| for (int i = 0; i < cryptogram.length() - 1; i++) { | ||
| if (cryptogram.charAt(i) == cryptogram.charAt(i + 1)) { | ||
| cryptogram = cryptogram.substring(0, i) + cryptogram.substring(i + 2); | ||
| i--; |
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.
개인적으로 i를 바꾸는 것은 위험하다고 생각합니다!
i를 바꿔야한다면, for문 대신 while문이 더 괜찮을 거 같아요
|
|
||
| public class Problem7 { | ||
|
|
||
| static HashMap<String, Integer> map = new HashMap<>(); |
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.
map 대신 더 좋은 네이밍이 있을 거 같아요
| List<String> userFriend = friendPoint(user, friends); | ||
| visitorPoint(visitors, userFriend); | ||
|
|
||
| List<Map.Entry<String, Integer>> entries = new ArrayList<>(map.entrySet()); |
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.
sort 과정을 함수로 뺄 수 있을 거 같아요
| int valueComp = entry2.getValue().compareTo(entry1.getValue()); | ||
| if(valueComp == 0) { | ||
| return entry1.getKey().compareTo(entry2.getKey()); | ||
| } else { |
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 문을 제거할 수 있을 거 같아요
| return answer; | ||
| } | ||
|
|
||
| public static List<String> friendPoint(String user, List<List<String>> friends) { |
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 static void visitorPoint(List<String> visitors, List<String> userFriend) { | ||
| for(int i = 0; i < visitors.size(); i++) { |
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.
index로 조회하는 것 보다 더 가독성 좋은 방법이 있습니다!
| for(int i = 0; i < visitors.size(); i++) { | |
| for(String visitor: visitors) { |
No description provided.