Open
Conversation
DWL21
reviewed
Dec 12, 2024
DWL21
left a comment
There was a problem hiding this comment.
https://github.com/woowacourse-precourse/java-oncall-6/blob/main/README.md
입출력 요구사항에서 예외 케이스 잘 찾고 과제 진행 요구 사항 지키면 좋은 점수 받을 수 있을겁니다.
좋은 결과 있었으면 좋겠네요.
| import oncall.view.InputView; | ||
| import oncall.view.OutputView; | ||
|
|
||
| public class CustomController extends ExceptionLoopController{ |
Comment on lines
+16
to
+61
| public class CustomService { | ||
| public List<MonthlyRoster> makeMonthlyRoster(MonthAndDayOfWeek monthAndDayOfWeek, CombinedRoster combinedRoster) { | ||
| int monthNumber = monthAndDayOfWeek.getMonthNumber(); // 5 | ||
| int lastDay = monthAndDayOfWeek.getLastDay(); // 31 | ||
|
|
||
| Roster weekdayRoster = combinedRoster.getWeekdayRoster(); | ||
| Roster weekendRoster = combinedRoster.getWeekendRoster(); | ||
|
|
||
| int dayOfWeekIndex = monthAndDayOfWeek.getDayOfWeekNumber(); // 월-1 , 일-7 | ||
| List<MonthlyRoster> monthlyRosters = new ArrayList<>(); | ||
|
|
||
| int weekdayIndex = 0; | ||
| int weekendIndex = 0; | ||
| String name = ""; | ||
| for (int day = 1; day <= lastDay; day++) { | ||
| boolean isHoliday = isHoliday(monthNumber, day, dayOfWeekIndex); | ||
| if (isHoliday) { | ||
| if(name.equals(weekendRoster.getWorkerNameByIndex(weekendIndex))){//이전 근무자와 이름이 연속되는지 확인 | ||
| weekendRoster.swapRoster(weekendIndex);//연속되면 스왑 | ||
| } | ||
| name = weekendRoster.getWorkerNameByIndex(weekendIndex); | ||
| weekendIndex += 1; | ||
| if(weekendIndex > weekendRoster.getRosterSize() - 1){ //순번 다 돌면 초기화 | ||
| weekendIndex = 0; | ||
| } | ||
| } | ||
| if (!isHoliday) { | ||
| if(name.equals(weekdayRoster.getWorkerNameByIndex(weekdayIndex))){//이전 근무자와 이름이 연속되는지 확인 | ||
| weekdayRoster.swapRoster(weekdayIndex);//연속되면 스왑 | ||
| } | ||
| name = weekdayRoster.getWorkerNameByIndex(weekdayIndex); | ||
| weekdayIndex += 1; | ||
| if(weekdayIndex > weekdayRoster.getRosterSize() - 1){ //순번 다 돌면 초기화 | ||
| weekdayIndex = 0; | ||
| } | ||
| } | ||
| //리스트에 추가 | ||
| monthlyRosters.add(new MonthlyRoster(monthNumber, day, getDayOfWeekName(dayOfWeekIndex), name, isHoliday)); | ||
|
|
||
| //요일 순번 다 돌면 초기화 | ||
| dayOfWeekIndex += 1; | ||
| if (dayOfWeekIndex > 7) { | ||
| dayOfWeekIndex = 1; | ||
| } | ||
| } | ||
| return monthlyRosters; |
There was a problem hiding this comment.
함수(또는 메서드)의 길이가 15라인을 넘어가지 않도록 구현한다.
함수(또는 메서드)가 한 가지 일만 하도록 최대한 작게 만들어라.
Comment on lines
+69
to
+77
| private boolean isHoliday(int month, int day, int dayOfWeekNumber) { | ||
| for (Holidays h : Holidays.values()) { | ||
| if (h.getMonth() == month && h.getDay() == day) { | ||
| return true; | ||
| } | ||
| } | ||
| if (DayOfWeek.of(dayOfWeekNumber) == DayOfWeek.SATURDAY || DayOfWeek.of(dayOfWeekNumber) == DayOfWeek.SUNDAY) { | ||
| return true; | ||
| } |
| if(weekdayWorkers.size() != weekendWorkers.size()){ | ||
| throw new IllegalInputException(); | ||
| } | ||
| // 중복 검사 로직은 나중에 |
| for (int day = 1; day <= lastDay; day++) { | ||
| boolean isHoliday = isHoliday(monthNumber, day, dayOfWeekIndex); | ||
| if (isHoliday) { | ||
| if(name.equals(weekendRoster.getWorkerNameByIndex(weekendIndex))){//이전 근무자와 이름이 연속되는지 확인 |
There was a problem hiding this comment.
indent(인덴트, 들여쓰기) depth를 3이 넘지 않도록 구현한다. 2까지만 허용한다.
예를 들어 while문 안에 if문이 있으면 들여쓰기는 2이다.
| @@ -1,5 +1,35 @@ | |||
| ### 미션 해결 전략 | |||
| #### 1. 본인이 이해하고 구현한 내용에 기반해 '다른 근무자와 순서를 바꿔야 하는 경우'를 자신만의 예시를 들어 설명하세요. (필수) | |||
There was a problem hiding this comment.
해당 경우 예외 처리가 안되어 있네요.
"4,월",
"a,b,c,d,e",
"a,b,c,d,e"
| for (int day = 1; day <= lastDay; day++) { | ||
| boolean isHoliday = isHoliday(monthNumber, day, dayOfWeekIndex); | ||
| if (isHoliday) { | ||
| if(name.equals(weekendRoster.getWorkerNameByIndex(weekendIndex))){//이전 근무자와 이름이 연속되는지 확인 |
There was a problem hiding this comment.
주석 대신 코드로 구현 의도를 설명하면 좋겠어요.
메서드를 분리하고 주석의 내용을 메서드 이름으로 하면 되겠네요.
Comment on lines
+18
to
+20
| int monthNumber = monthAndDayOfWeek.getMonthNumber(); // 5 | ||
| int lastDay = monthAndDayOfWeek.getLastDay(); // 31 | ||
|
|
There was a problem hiding this comment.
Suggested change
| int monthNumber = monthAndDayOfWeek.getMonthNumber(); // 5 | |
| int lastDay = monthAndDayOfWeek.getLastDay(); // 31 | |
| final int monthNumber = monthAndDayOfWeek.getMonthNumber(); // 5 | |
| final int lastDay = monthAndDayOfWeek.getLastDay(); // 31 | |
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.