我试图自己实施SM2。我找到了两个来源作为我对这种做法的参考。
问题1 我很困惑。哪一个是正确的?我无法完全理解SM2的正确实现。
问题2 我尝试关注FIRST ONE的博客,以下是我的代码。我做对了吗?帮助真的很感激。
algorithm-sm2
public abstract class SM2_Impl {
private Double easiness = new Double(2.5);
private Double consecutiveCorrectAnswers = new Double(0);
private Double nextDueDate = new Double(0);
public Double getEasiness() {
return easiness;
}
public void setEasiness(Double easiness) {
this.easiness = easiness;
}
public Double getConsecutiveCorrectAnswers() {
return consecutiveCorrectAnswers;
}
public void setConsecutiveCorrectAnswers(Double consecutiveCorrectAnswers) {
this.consecutiveCorrectAnswers = consecutiveCorrectAnswers;
}
public Double getNextDueDate() {
return nextDueDate;
}
public void setNextDueDate(Double nextDueDate) {
this.nextDueDate = nextDueDate;
}
public void ans(PerformanceRatingEnum performanceRating) {
performanceRating.getLevel();
this.easiness += -0.8 + 0.28*performanceRating.getLevel() + 0.02*Math.pow(performanceRating.getLevel(), 2);
if (this.easiness < 1.3) {
this.easiness = 1.3; // the min val
}else if (this.easiness > 3) {
this.easiness = 3.0; // the max val
}
switch(performanceRating) {
case CORRECT_RESPONSE_03:
case CORRECT_RESPONSE_04:
case PERFECT_RESPONSE_05:
this.consecutiveCorrectAnswers++;
this.nextDueDate = this.nextDueDate + (6 * Math.pow(this.easiness, this.consecutiveCorrectAnswers - 1));
break;
case COMPLETE_BLACKOUT_00:
case INCORRECT_RESPONSE_01:
case INCORRECT_RESPONSE_02:
this.consecutiveCorrectAnswers = 0.0;
this.nextDueDate = this.nextDueDate + 1;
break;
default:
break;
}
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
问题3 一旦我得到了正确的算法实现,我该如何测试呢?如果有人可以建议测试场景,那将非常有用。