values of variables changing despite not modifying them
Hi,
My problem is in the following code. The code with *** is changing the values of sensors.get(i).getTemperature and/or sensors.get(j).getTemperature. If I leave this line out, the temperatures appear normal. With that line, they take unexpected large negative values. Anyone know what's going on and have a possible solution? Thanks
Code :
public static boolean verifyAssessor( Assessor assessor, List<Sensor> sensors)
{
boolean result = true;
int i,j;
int consistentWith = 0;
int functioningSensors = 0;
for(i=0;i<sensors.size();i++){
consistentWith = 0;
for(j=0;j<sensors.size();j++){
if(i!=j){
if(Math.abs(sensors.get(i).getTemperature()-sensors.get(j).getTemperature())/sensors.get(i).getTemperature() <=
Assessor.ERROR && sensors.get(i).getTemperature()!=-1 && sensors.get(j).getTemperature()!=-1){
consistentWith ++; //***
}
}
}
//Count the number of functioning sensors
if(consistentWith>=2){
functioningSensors ++;
}
}
Re: values of variables changing despite not modifying them
Can you put your format your Code Correctly?
Edit Post > "#" Symbol > Copy & Paste Code into Tags