1
Good Afternoon!!... I have the following question... I have an Enum class and in it within each "option" I perform a calculation when selecting... How would make that calculation run and so, I have a result?
see the code snippet:
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 that when I select a combobox item it calls the method, I tried to use the event that follows below but it gives error, because it does not recognize the class coefficients A (Coefficient newValue) as an object, I need it to run when I select, because I need the data returned by the function above.
comboboxCoefA.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {
public void changed(ObservableValue observable, Object oldValue, CoeficienteA newValue) {
newValue.Exponencial.calcular(fruto);
}
}
});
I need that when I select a combobox item it calls a method, that runs only when I select, because I need the data returned by the function.
– Sara Fernandes