Skip to content

Instantly share code, notes, and snippets.

@W4RH4WK
Created April 30, 2013 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save W4RH4WK/5491893 to your computer and use it in GitHub Desktop.
Save W4RH4WK/5491893 to your computer and use it in GitHub Desktop.
Java Finite State Machine
public class Main {
public static void main(String[] args) {
SensorState s = SensorState.One;
s = s.run();
s = s.run();
}
}
public enum SensorState {
One {
public SensorState run() {
System.out.println("State One");
return Two;
}
},
Two {
public SensorState run() {
System.out.println("State Two");
return One;
}
};
abstract public SensorState run();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment