Ejemplo n.º 1
0
    public void UpdateResult(string input)
    {
        switch (input)
        {
        case Inputs.CHANGE_SIGN:
            if (textComponent.text.Length > 0)
            {
                textComponent.text = (int.Parse(textComponent.text) * (-1)).ToString();
            }
            break;

        case Inputs.BACK:
            textComponent.text = "";
            break;

        //TO DO
        case Inputs.CHECK:
            bool correctAnswer = int.TryParse(textComponent.text, out int result) && taskGenerator.CheckAnswer(result);
            scoreManager.UpdateScore(correctAnswer);
            textComponent.text = "";

            break;

        default:
            if (Int32.TryParse(input, out int res))
            {
                if (textComponent.text == "0")
                {
                    textComponent.text = "";
                }

                string newText = textComponent.text + input;
                if (Math.Abs(int.Parse(newText)) < 999)
                {
                    textComponent.text = newText;
                }
            }
            break;
        }
    }