ruleBlock.setName("No1");
ruleBlock.setRuleAccumulationMethod(new RuleAccumulationMethodMax());
ruleBlock.setRuleActivationMethod(new RuleActivationMethodMin());
// RULE 1 : IF service IS poor OR food is rancid THEN tip IS cheap;
Rule rule1 = new Rule("Rule1", ruleBlock);
rule1.addAntecedent(service, "poor", false);
rule1.addAntecedent(food, "rancid", false);
rule1.addConsequent(tip, "cheap", false);
ruleBlock.add(rule1);
// RULE 2 : IF service IS good THEN tip IS average;
Rule rule2 = new Rule("Rule2", ruleBlock);
rule2.addAntecedent(service, "good", false);
rule2.addConsequent(tip, "average", false);
ruleBlock.add(rule2);
// RULE 3 : IF ((service IS good) OR (service IS excellent)) AND food IS delicious THEN tip is generous;
Rule rule3 = new Rule("Rule3", ruleBlock);
RuleTerm term1 = new RuleTerm(service, "good", false); // Create 'terms'
RuleTerm term2 = new RuleTerm(service, "excellent", false);
RuleTerm term3 = new RuleTerm(food, "delicious", false);
RuleExpression antecedentOr = new RuleExpression(term1, term2, new RuleConnectionMethodOrMax()); // Combine terms using connection methods: OR, AND
RuleExpression antecedentAnd = new RuleExpression(antecedentOr, term3, new RuleConnectionMethodAndMin());
rule3.setAntecedents(antecedentAnd); // Set antecedent
rule3.addConsequent(tip, "generous", false);
ruleBlock.add(rule3);
// END_RULEBLOCK
//
// END_FUNCTION_BLOCK