package edu.redwoods.state;
public class TVRemote {
public static void main(String[] args) {
// State client 1 completely decoupled from states.
TVContext context1 = new TVContext(true);
context1.doAction(); // State transition 1
context1.doAction(); // State transition 2, polymorphic behavior!!!
// State client 2 where the client controls the states and transitions!
State tvStartState = new TVStartState();
State tvStopState = new TVStopState();
TVContext context2 = new TVContext();
context2.setState(tvStartState);
context2.doAction();
context2.setState(tvStopState);
context2.doAction();
// State client 3 where client sets up transitions, but they are automatic
TVContext context3 = new TVContext();
State tvStartState2 = new TVStartState(context3);
State tvStopState2 = new TVStopState(context3, tvStartState2);
context3.setState(tvStopState2);
tvStartState2.setTransition(tvStopState2);
context3.doAction();
context3.doAction();
}
}