MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / Washer

Class Washer

patterns/state/StateMachineDemo.java:48–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46}
47
48class Washer extends StateMachine {
49 private int i = 0;
50 private Iterator<State> states =
51 Arrays.asList(
52 new Wash(), new Spin(),
53 new Rinse(), new Spin()
54 ).iterator();
55 Washer() { runAll(); }
56 @Override public boolean changeState() {
57 if(!states.hasNext())
58 return false;
59 // Set the surrogate reference
60 // to a new State object:
61 currentState = states.next();
62 return true;
63 }
64}
65
66public class StateMachineDemo {
67 public static void main(String[] args) {

Callers

nothing calls this directly

Calls 1

iteratorMethod · 0.45

Tested by

no test coverage detected