// ForwardBehavior.java // // A behaviour for the LeJOS behaviour-based approach. // Drives the robot forward, based on the original // code by Simon Parsons, 2013. // // Terry Payne // 6th October 2017 // import lejos.robotics.subsumption.Behavior; public class ForwardBehaviour implements Behavior{ public boolean suppressed; private SimpleRobot robot; public ForwardBehaviour(SimpleRobot r){ robot = r; } public void suppress(){ suppressed = true; } // Start driving and then yield (for a non-busy wait). If // suppressed, then stop the motors and quit. public void action(){ suppressed = false; robot.startMotors(); while(!suppressed){ Thread.yield(); } robot.stopMotors(); } public boolean takeControl(){ return true; } }