Skip to content

Commit

Permalink
refactor: Handler 클래스 필드 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
stophwan committed Jun 11, 2024
1 parent db980ea commit ccf7220
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public DetailCategoryResult createDetailCategoryResult(User user, TakenLectureIn
for (MandatoryMajorSpecialCaseHandler mandatoryMajorSpecialCaseHandler : mandatoryMajorSpecialCaseHandlers) {
if (mandatoryMajorSpecialCaseHandler.isSupport(user, majorGraduationCategory)) {
MandatorySpecialCaseInformation mandatorySpecialCaseInformation = mandatoryMajorSpecialCaseHandler.getMandatorySpecialCaseInformation(
takenLectureInventory, mandatoryLectures, electiveLectures);
user, majorGraduationCategory, takenLectureInventory, mandatoryLectures, electiveLectures);
isSatisfiedMandatory = mandatorySpecialCaseInformation.isCompleteMandatorySpecialCase();
removeMandatoryTotalCredit = mandatorySpecialCaseInformation.getRemovedMandatoryTotalCredit();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
public interface MandatoryMajorSpecialCaseHandler {
boolean isSupport(User user, MajorGraduationCategory majorGraduationCategory);

MandatorySpecialCaseInformation getMandatorySpecialCaseInformation(TakenLectureInventory takenLectureInventory,
MandatorySpecialCaseInformation getMandatorySpecialCaseInformation(
User user, MajorGraduationCategory majorGraduationCategory, TakenLectureInventory takenLectureInventory,
Set<Lecture> mandatoryLectures, Set<Lecture> electiveLectures);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,27 @@ public class OptionalMandatoryMandatoryMajorHandler implements MandatoryMajorSpe
private static final String INTERNATIONAL_TRADE = "국제통상학과";
private static final int CLASS_OF_17 = 17;
private static final int CLASS_OF_19 = 19;
private OptionalMandatory optionalMandatory;

public boolean isSupport(User user, MajorGraduationCategory majorGraduationCategory) {
String calculatingMajor = getCalculatingMajor(user, majorGraduationCategory);
if (calculatingMajor.equals(MANAGEMENT_INFORMATION) && user.getEntryYear() >= CLASS_OF_19) {
this.optionalMandatory = OptionalMandatory.from(getCalculatingMajor(user, majorGraduationCategory));
return true;
}
if (calculatingMajor.equals(ADMINISTRATIONS) && user.getEntryYear() >= CLASS_OF_17) {
this.optionalMandatory = OptionalMandatory.from(getCalculatingMajor(user, majorGraduationCategory));
return true;
}
if (List.of(BUSINESS, INTERNATIONAL_TRADE).contains(calculatingMajor)) {
this.optionalMandatory = OptionalMandatory.from(getCalculatingMajor(user, majorGraduationCategory));
return true;
}
return false;
return List.of(BUSINESS, INTERNATIONAL_TRADE).contains(calculatingMajor);
}

@Override
public MandatorySpecialCaseInformation getMandatorySpecialCaseInformation(
TakenLectureInventory takenLectureInventory, Set<Lecture> mandatoryLectures, Set<Lecture> electiveLectures) {
User user, MajorGraduationCategory majorGraduationCategory, TakenLectureInventory takenLectureInventory,
Set<Lecture> mandatoryLectures, Set<Lecture> electiveLectures) {

OptionalMandatory optionalMandatory = OptionalMandatory.from(getCalculatingMajor(user, majorGraduationCategory));
int removedMandatoryTotalCredit = 0;
boolean completeMandatorySpecialCase = checkCompleteOptionalMandatory(takenLectureInventory, mandatoryLectures,
electiveLectures);
electiveLectures, optionalMandatory);

if (!completeMandatorySpecialCase) {
removedMandatoryTotalCredit = optionalMandatory.getTotalOptionalMandatoryCredit()
Expand All @@ -63,7 +58,7 @@ public MandatorySpecialCaseInformation getMandatorySpecialCaseInformation(
}

private boolean checkCompleteOptionalMandatory(TakenLectureInventory takenLectureInventory,
Set<Lecture> mandatoryLectures, Set<Lecture> electiveLectures) {
Set<Lecture> mandatoryLectures, Set<Lecture> electiveLectures, OptionalMandatory optionalMandatory) {
int chooseNum = optionalMandatory.getChooseNumber();
/*
* 전공과목 Set 에서 전공선택필수과목에 해당되는 과목들을 추출한다.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public boolean isSupport(User user, MajorGraduationCategory majorGraduationCateg

@Override
public MandatorySpecialCaseInformation getMandatorySpecialCaseInformation(
TakenLectureInventory takenLectureInventory, Set<Lecture> mandatoryLectures, Set<Lecture> electiveLectures) {
User user, MajorGraduationCategory majorGraduationCategory, TakenLectureInventory takenLectureInventory, Set<Lecture> mandatoryLectures, Set<Lecture> electiveLectures) {
boolean completeMandatorySpecialCase = checkCompleteReplaceMandatory(takenLectureInventory, mandatoryLectures,
electiveLectures);
int removedMandatoryTotalCredit = 0;
Expand Down

0 comments on commit ccf7220

Please sign in to comment.