Example #1
0
        public static void RegisterCommand(ICommand command)
        {
            if (!(command is ISpell) && command.GetWords().Contains(' '))
                throw new Exception("Command words cannot contain spaces.");

            LinkedListNode<ICommand> lastNode = commandList.First;

            if (lastNode == null)
            {
                commandList.AddFirst(command);
            }
            else
            {
                while (lastNode.Next != null &&
                    lastNode.Value.GetWords().Length > command.GetWords().Length)
                {
                    lastNode = lastNode.Next;
                }
                commandList.AddAfter(lastNode, command);
            }
        }
Example #2
0
        public static void RegisterCommand(ICommand command)
        {
            if (!(command is ISpell) && command.GetWords().Contains(' '))
            {
                throw new Exception("Command words cannot contain spaces.");
            }

            LinkedListNode <ICommand> lastNode = commandList.First;

            if (lastNode == null)
            {
                commandList.AddFirst(command);
            }
            else
            {
                while (lastNode.Next != null &&
                       lastNode.Value.GetWords().Length > command.GetWords().Length)
                {
                    lastNode = lastNode.Next;
                }
                commandList.AddAfter(lastNode, command);
            }
        }