package RCX3.docs; import josx.platform.rcx.SensorListener; import josx.platform.rcx.Sensor; /** *A listener for the light sensor. */ public class LightListener implements SensorListener { public void stateChanged(Sensor aSource, int aOldValue, int aNewValue) { int howFarFromWhite = Math.abs(aNewValue-Senses.white); int howFarFromBlack = Math.abs(aNewValue-Senses.black); if (howFarFromWhite > howFarFromBlack){ PrettyBoy.lightFlag = true;//if white }else{ PrettyBoy.lightFlag = false;//if black } }//stateChanged }//LightListener