Reputation: 11
I want to return the result of the fuzzy logic as a double to be used by another class. I am using the following java code:
public class MyFuzzyClass {
public double getFuzzy() {
String fileName = "tipper.fcl"; //we have to add this file
FIS fis = FIS.load(fileName,true);
if( fis == null ) { // Error while loading?
System.err.println("Can't load file: '" + fileName + "'");
return;
}
// show rule set
FunctionBlock functionBlock = fis.getFunctionBlock(null);
JFuzzyChart.get().chart(functionBlock);
// set inputs
functionBlock.setVariable("service", 3);
functionBlock.setVariable("food", 7);
// evaluate
functionBlock.evaluate();
Variable tip = functionBlock.getVariable("tip");
Double tip_new = tip.getValue();
System.out.println("Tip:" + functionBlock.getVariable("tip").getValue());
return tip_new;
}
}
But I got an error in this return statement:
if( fis == null ) { // Error while loading?
System.err.println("Can't load file: '" + fileName + "'");
return;
}
How can I solve this error??
Upvotes: 1
Views: 281