Beispiel #1
0
        static void Main(string[] args)
        {
            Context   context    = new Context();
            PlayMusic startState = new PlayMusic();

            startState.doAction(context);
            Console.WriteLine(context.getState().toString());

            StopMusic stopState = new StopMusic();

            stopState.doAction(context);
            Console.WriteLine(context.getState().toString());

            Console.Read();
        }
        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());
        }
        static void Main(string[] args)
        {
            // Use Context to see changes in behaviour when changing state.
            Context context = new Context();

            ConcreteStateA stateA = new ConcreteStateA();
            stateA.handle(context);

            Console.WriteLine(context.getState().response());

            ConcreteStateB stateB = new ConcreteStateB();
            stateB.handle(context);

            Console.WriteLine(context.getState().response());

            Console.WriteLine("Press enter to close...");
            Console.ReadLine();
        }