main.m668 chars28 lines
This class defines a state machine with two states 'on' and 'off' and two transition functions 'switchon' and 'switchoff'. The state machine is initialized with the initial state, which could be either 'on' or 'off'. The switchon and switchoff methods transition the state machine between states while checking if the desired state is not the current state. If the desired state is the same as the current state, an error is thrown.
gistlibby LogSnag