/* * This tiny class operates the SensorListeners for PrimitiveNav. * This is looking for a significant change in light values, which signify that * its environment has varied. It then switches the bool variable in * PrimitiveNav that interrupts the loop that keeps the motors running. * * ********************** * Julie Powers-Boyle * 20060301, Wed; Programming WS * $id * ********************** */ import josx.platform.rcx.*; public class PrimitiveWatcher implements SensorListener{ public void stateChanged(Sensor whichSensor, int lastValue, int newValue) { if (PrimitiveNav.goingBackward == false){ if (Math.abs(lastValue - newValue) > 2) { // this will interrupt explore's while loop PrimitiveNav.different = true; } } else if (whichSensor != Sensor.S2) { if (Math.abs(lastValue - newValue) > 2) { // this will interrupt explore's while loop PrimitiveNav.different = true; } } } }