【发布时间】:2012-11-09 15:48:20
【问题描述】:
我有一个用例,其中一个对象存在一个字符串,该字符串具有针对另一个对象的属性进行评估的条件。
例如。
StudentEvaluator有条件
student.pastScore>70 && student.currentScore>90 && student.sportsParticipation=true
并且Student 对象具有各自的属性。
E.g. pastScore, currentScore and sportsParticipation
现在StudentEvaluator 条件字符串是在运行时创建的,并且必须评估真假。
有许多 StudentEvaluator 在不同的条件下并行运行。
现在 StudentEvaluator 在其评估函数中接受一个学生参数并评估条件。
即
public Class StudentEvaluator{
String condition;
public StudentEvaluator(String condition){
this.condition = condition;
}
evaluate(Student student){
<<Code>>
}
}
评估最有效的方法是什么? 欢迎任何开箱即用的想法! :)
【问题讨论】:
标签: java oop conditional-statements evaluation