static void Main(string[] args) { Context context = new Context(); IState startState = new StartState(); startState.DoAction(context); Console.WriteLine(context.GetState().MyState()); IState stopState = new StopState(); stopState.DoAction(context); Console.WriteLine(context.GetState().MyState()); }
static void Main(string[] args) { Context context = new Context(); StartState start = new StartState(); start.Do(context); Console.WriteLine(context.state); StopState stop = new StopState(); stop.Do(context); Console.WriteLine(context.state); }
public static void Main(string[] args) { Context context = new Context(); StartState startState = new StartState(); startState.DoAction(context); Console.WriteLine(context.GetState().ToString()); StopState stopState = new StopState(); stopState.DoAction(context); Console.WriteLine(context.GetState().ToString()); Console.ReadLine(); }
static void Main(string[] args) { var context = new Context(); var startState = new StartState(); startState.Handle(context); Console.WriteLine(context.GetState().ToString()); var stopState = new StopState(); stopState.Handle(context); Console.WriteLine(context.GetState().ToString()); Console.ReadKey(); }