Пример #1
0
        public void CheckAndChangeState()
        {
            Transition transition = currentState.GetEnabledTransition();

            if (transition != null)
            {
                Console.Write("由“" + currentState.GetName() + "”状态");

                currentState = transition.GetEnd();

                Console.WriteLine("到“" + currentState.GetName() + "”状态。");

                if (currentState.GetId() == startState.GetId())
                {
                    RestoreAllStates();
                }
            }
            else
            {
                currentState.DoAction();
            }
        }