Exit.java
package Caprani;
import lejos.nxt.Button;
import lejos.nxt.LCD;
import lejos.nxt.Motor;
import lejos.robotics.subsumption.Behavior;
 
public class Exit implements Behavior {
 
    private Button button;
    private boolean suppressed = false;
    private boolean pressed = false;
 
    public Exit(Button button) {
        this.button = button;
    }
 
    @Override
    public boolean takeControl() {
        if (button.isPressed()) {
            pressed = true;
        }
        return pressed;
    }
 
    @Override
    public void suppress() {
        suppressed = true;
    }
 
    @Override
    public void action() {
        suppressed = false;
        Motor.A.stop();
        Motor.C.stop();
 
        System.exit(0);
    }
 
}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License