public bool CanAddValue()
        {
            //value input after another value, unary operators or right parenthesis is not allowed
            var invalidTypes = new HashSet <KeyType>()
            {
                KeyType.Value,
                KeyType.Unary,
                KeyType.Right
            };

            return(!invalidTypes.Contains(KeyHistory.Last()));
        }
        private void AddLeftParenthesis(string input)
        {
            //left parenthesis cannot immediately follow a value or unary operator
            if (KeyHistory.Last() == KeyType.Value || KeyHistory.Last() == KeyType.Unary)
            {
                throw new InvalidOperationException("Missing Operators.");
            }
            //left parenthesis cannot immediately follow right parenthesis
            if (KeyHistory.Last() == KeyType.Right)
            {
                throw new InvalidOperationException("Mismatched Parentheses.");
            }

            Buffer.Add(input);
            KeyHistory.Add(KeyType.Left);
        }
        public void AddBinary(string input)
        {
            //consecutive binary operator input is not allowed
            if (KeyHistory.Last() == KeyType.Binary)
            {
                throw new InvalidOperationException("Missing Operand.");
            }

            /*
             * when binary operator input follows left parenthesis or nothing,
             * a value of zero will be added as default operand
             */
            if (KeyHistory.Last() == KeyType.Left || KeyHistory.Last() == KeyType.Empty)
            {
                AddValue(0);
            }

            Buffer.Add(input);
            KeyHistory.Add(KeyType.Binary);
        }
        private void AddRightParenthesis(string input)
        {
            //right parenthesis cannot immediately follow binary operator
            if (KeyHistory.Last() == KeyType.Binary)
            {
                throw new InvalidOperationException("Missing Operand.");
            }
            //parentheses must match
            if (MissingParentheses(Expression) < 1)
            {
                throw new InvalidOperationException("Mismatched Parentheses.");
            }

            if (KeyHistory.Last() == KeyType.Left)
            {
                AddValue(0);
            }

            Buffer.Add(input);
            KeyHistory.Add(KeyType.Right);
        }