Exemple #1
0
        public void HandleEvent(FlashLightEvent evt)
        {
            switch (_currentState)
            {
                case FlashLightState.On:
                    _currentState = FlashLightState.Off;
                    Off();
                    break;

                case FlashLightState.Off:
                    _currentState = FlashLightState.On;
                    On();
                    break;
            }
        }
        public void HandleEvent(FlashLightEvent evt)
        {
            switch (_currentState)
            {
            case FlashLightState.On:
                _currentState = FlashLightState.Off;
                Console.WriteLine("Flaslight off");
                break;

            case FlashLightState.Off:
                _currentState = FlashLightState.On;
                Console.WriteLine("Flaslight on");
                break;
            }
        }
Exemple #3
0
        public void HandleEvent(FlashLightEvent evt)
        {
            switch (_currentState)
            {
            case FlashLightState.On:
                _currentState = FlashLightState.Off;
                Off();
                break;

            case FlashLightState.Off:
                _currentState = FlashLightState.On;
                On();
                break;
            }
        }
        public void SetState(FlashLightEvent evt)
        {
            switch (_currentState)
            {
            case FlashLightstate.On:
                _currentState = FlashLightstate.Off;
                Console.WriteLine("Flashlight Off");
                break;

            case FlashLightstate.Off:
                _currentState = FlashLightstate.On;
                Console.WriteLine("Flashlight On");
                break;
            }
        }
Exemple #5
0
        public void HandleEvent(FlashLightEvent evt)
        {
            while (true)
            {
                switch (_currentState)
                {
                case FlashLightState.On:
                    _currentState = FlashLightState.Off;
                    Console.WriteLine("Turned off");
                    Thread.Sleep(500);
                    break;

                case FlashLightState.Off:
                    _currentState = FlashLightState.On;
                    Console.WriteLine("Turned On");
                    Thread.Sleep(500);
                    break;
                }
            }
        }