Greetings and Wizard assignment

Hi, I’m from Colombia, 24 years old man. Here’s my task:

public class HelloWorld : MonoBehaviour
{
    int max = 1000;
    int min = 1;
    int guess = 500;
    // Start is called before the first frame update
    void Start()
    {
       
        Debug.Log($"Piensa en un numero entre {min} y {max}");
        Debug.Log("Tu numero es mayor o menor que 500");
        Debug.Log("Push up = Mayor, Push down = Lower, Push enter = Correct");
        max += 1;
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            min = guess; //we're redefining what's min
            guess = (max + min) / 2;
            Debug.Log($"it's higher or lower than {guess}");
                //guess is updated and now min = 750  
        }
        else if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            max = guess; //se redefine qué es max
            guess = (min + max) / 2;
            Debug.Log($"it's higher or lower than {guess}");

        }
        else if(Input.GetKeyDown(KeyCode.Return))
        {
            Debug.Log("Enter was pressed");
        }
    }
}

Srry I kinda used Spanish here and there, I’ll try to use more English on other assignments…

Also, have you notice that there is a problem once it reaches certain numbers like 985 you cant go up or down from there, or 1000 you can´t go down.

2 Likes

I never coded in Spanish before. This is so cool to read!

1 Like

Privacy & Terms