Skip to content

Commit

Permalink
fix(#74): score round to 3
Browse files Browse the repository at this point in the history
  • Loading branch information
gimhanul committed Sep 12, 2023
1 parent 87478fd commit 7625d08
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bamdoliro.maru.domain.form.domain.value;

import com.bamdoliro.maru.shared.util.MathUtil;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import lombok.AccessLevel;
Expand Down Expand Up @@ -41,11 +42,11 @@ public class Score {
private Double totalScore;

public Score(Double subjectGradeScore, Integer attendanceScore, Integer volunteerScore, Integer bonusScore) {
this.subjectGradeScore = subjectGradeScore;
this.subjectGradeScore = MathUtil.roundTo(subjectGradeScore, 3);
this.attendanceScore = attendanceScore;
this.volunteerScore = volunteerScore;
this.bonusScore = bonusScore;
this.firstRoundScore = subjectGradeScore + attendanceScore + volunteerScore + bonusScore;
this.firstRoundScore = MathUtil.roundTo(subjectGradeScore + attendanceScore + volunteerScore + bonusScore, 3);
}

public void updateSubjectScore(Double subjectGradeScore) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.bamdoliro.maru.domain.form.domain.value.Attendance;
import com.bamdoliro.maru.domain.form.domain.value.Score;
import com.bamdoliro.maru.domain.form.domain.value.SubjectMap;
import com.bamdoliro.maru.shared.util.MathUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

Expand All @@ -22,7 +21,7 @@
import static com.bamdoliro.maru.domain.form.constant.FormConstant.MIN_VOLUNTEER_SCORE;
import static com.bamdoliro.maru.domain.form.constant.FormConstant.MIN_VOLUNTEER_TIME;
import static com.bamdoliro.maru.domain.form.constant.FormConstant.REGULAR_TYPE_DEFAULT_SCORE;
import static com.bamdoliro.maru.domain.form.constant.FormConstant.SPECIAL_TYPE_DEFAULT_SCORE ;
import static com.bamdoliro.maru.domain.form.constant.FormConstant.SPECIAL_TYPE_DEFAULT_SCORE;

@RequiredArgsConstructor
@Service
Expand Down Expand Up @@ -63,7 +62,7 @@ private Double calculateRegularScore(Form form) {
7.2 * 2 * subjectMap.getScoreOf(3, 1);
}

return REGULAR_TYPE_DEFAULT_SCORE + MathUtil.roundTo(score, 3);
return REGULAR_TYPE_DEFAULT_SCORE + score;
}

private Double calculateSpecialScore(Form form) {
Expand All @@ -77,7 +76,7 @@ private Double calculateSpecialScore(Form form) {
4.32 * 2 * subjectMap.getScoreOf(3, 1);
}

return SPECIAL_TYPE_DEFAULT_SCORE + MathUtil.roundTo(score, 3);
return SPECIAL_TYPE_DEFAULT_SCORE + score;
}

private Integer calculateAttendanceScore(Form form) {
Expand Down

0 comments on commit 7625d08

Please sign in to comment.