Esempio n. 1
0
        public void AcceptUserInputForAction(string input)
        {
            if (input != "lastq")
            {
                stack.SetLastExpOrCommand(input);
            }
            switch (input.ToLower())
            {
            case "remove all":
            case "clear all":
            case "delete all":
            {
                variableRepo.RemoveAllVariables();
                Console.WriteLine(dialog.ClearAllResponse());
                break;
            }

            case "exit":
            case "quit":
            {
                UserIsReadyToExit = true;
                Console.WriteLine(dialog.ExitResponse());
                Console.ReadKey();
                break;
            }

            case "show all":
            case "list all":
            {
                ShowProperResponseToListAllQuery();
                break;
            }

            case "lastq":
            {
                Console.WriteLine(stack.LastExpOrCommand);
                break;
            }

            case "help":
            {
                Console.WriteLine(dialog.HelpResponse());
                break;
            }

            default:
            {
                assignment.CheckIfUserInputIsValid(input);

                if (assignment.IsInputValid)
                {
                    if (!assignment.ValueUnchanged)
                    {
                        AddAndRespondToNewVariableAssignment();
                    }
                    else
                    {
                        DetermineIfUserWantsToShowOrRemoveItem();
                    }
                }
                else
                {
                    Console.WriteLine(dialog.CommandNotRecognized());
                }
                ResetAssignmentBooleans();
                break;
            }
            }
        }