package rules;
import com.dream21th.drools.study.demo2.Student;
rule "demo2_1"
when
$s:Student( age<10)
then
System.out.println("触发demo2_1:年龄小于"+$s.getAge());
$s.setResult("触发demo2_1:年龄小于"+$s.getAge());
end
rule "demo2_2"
when
$s:Student( age==10)
then
System.out.println("触发demo2_2:年龄等于"+$s.getAge());
$s.setResult("触发demo2_2:年龄等于"+$s.getAge());
end
rule "demo2_3"
when
$s:Student( age>10)
then
System.out.println("触发demo2_3:年龄大于"+$s.getAge());
$s.setResult("触发demo2_3:年龄大于"+$s.getAge());
end
rule "demo2_4"
when
$s:Student( age>10 && sex=="男")
then
System.out.println("触发demo2_4:年龄大于"+$s.getAge()+"且性别:"+$s.getSex());
$s.setResult("触发demo2_4:年龄大于"+$s.getAge()+"且性别:"+$s.getSex());
end
rule "demo2_5"
when
$s:Student( age>10 && sex=="女")
then
System.out.println("触发demo2_5:年龄大于"+$s.getAge()+"且性别:"+$s.getSex());
$s.setResult("触发demo2_5:年龄大于"+$s.getAge()+"且性别:"+$s.getSex());
end