Exemplo n.º 1
0
        private string GetExpression(List <OperationBase> checkedOperations, int numbers)
        {
            string exp = string.Empty;

            int[] arr = new int[numbers];
            for (int i = 0; i < numbers; i++)
            {
                OperationBase operation = GetOperation(checkedOperations, checkedOperations.Count);
                if (i == 0)
                {
                    arr[i] = operation.GenerateFirstNumber();
                    exp   += arr[i];
                    continue;
                }

                int start = arr[i - 1];
                int value = operation.GenerateNextNumber(start);
                exp   += (operation.Operator + value);
                arr[i] = Convert.ToInt32(new DataTable().Compute(exp.Replace('x', '*'), null));

                if (i == numbers - 1)
                {
                    exp += "=";
                }
            }

            return(exp);
        }