Good afternoon !! ... I have the following doubt ... I have an Enum class and in it within each "option" I execute a calculation when selecting ... How would I do this calculation to be executed and thus, I have a result?
see the snippet of code:
public enum CoeficienteA implements EquacaoCamFinaInterface {
Polinomial {
@Override
public double calcular(Fruto fruto) {//Poli
double a;
a = fruto.getA1() + fruto.getA2() * fruto.getCondicao().getTempeSgm() + fruto.getA3() * Math.pow(fruto.getCondicao().getTempeSgm(), 2) + fruto.getA4() * Math.pow(fruto.getCondicao().getTempeSgm(), 3)
+ fruto.getA5() * Math.pow(fruto.getCondicao().getTempeSgm(), 4) + fruto.getA6() * Math.pow(fruto.getCondicao().getTempeSgm(), 5) + fruto.getA7() * Math.pow(fruto.getCondicao().getTempeSgm(), 6)
+ fruto.getA8() * Math.pow(fruto.getCondicao().getTempeSgm(), 7);
return a;
}
},
Exponencial {
@Override
public double calcular(Fruto fruto) {
double a;
a = fruto.getA1() + Math.exp(-fruto.getA2() * fruto.getCondicao().getTempeSgm());
return a;
}
};
}
I need to select a combobox item to call the method, I tried to use the following event but it gives error, because it does not recognize the class coefficientA (CoefficientA newValue) as an object, I need it to execute when I select , because I need the data returned by the above function.
comboboxCoefA.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {
public void changed(ObservableValue observable, Object oldValue, CoeficienteA newValue) {
newValue.Exponencial.calcular(fruto);
}
}
});