Beispiel #1
0
        public void DoAction(string action)
        {
            string[] args = action.Split(" ", 2);

            string verb = args[0].ToUpper();

            if (ActionVerbs.Contains(verb) && (args.Length < 2 || args[1].Trim().Length < 1))
            {
                Console.WriteLine(string.Format(InfoFormatString, $"{verb} is missing second argument."));
                return;
            }

            if (ActionVerbs.Contains(verb) && IncompleteDescription.Contains(args[1]))
            {
                Console.WriteLine(string.Format(InfoFormatString, $"{args[1]} is a incomplete description."));
                return;
            }

            switch (verb)
            {
            case "ADD":
                _list.AddElement(args[1]);
                break;

            case "DO":
                string RemovedHashTag = args[1].Replace("#", string.Empty);
                _list.DoElement(RemovedHashTag);
                break;

            case "PRINT":
                _list.PrintElements();
                break;

            case "HELP":
                Console.WriteLine(HelpString);
                break;

            case "QUIT":
                System.Environment.Exit(1);
                break;

            default:
                Console.WriteLine("Unkown action. Type 'Help' for available actions.");
                break;
            }
        }