Number wizard test passed

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NumberWizard : MonoBehaviour
{
int max = 1000;
int min = 1;
int guess = 500;

// Start is called before the first frame update
void Start()
{
   

    Debug.Log("Hi there,welcome to the guess number game.");
    Debug.Log("Pick a number and dont tell me what it is ...shhhhhhh!!!!! ");
    Debug.Log("Highest Number to chose is : " + max);
    Debug.Log("Lowest Number you can chose is : " + min);
    Debug.Log("Tell me if the number is lower or higher then 500");
    Debug.Log("Push UP = Higher , Push DOWN = Lower , Push ENTER if is Correct");
    Debug.Log("LETS GET STARTED!!!");
    Debug.Log("LETS GET STARTED!!!");
    Debug.Log("LETS GET STARTED!!!");
    Debug.Log("LETS GET STARTED!!!");
    Debug.Log("LETS GET STARTED!!!");
    Debug.Log("LETS GET STARTED!!!");
    Debug.Log("LETS GET STARTED!!!");
    Debug.Log("LETS GET STARTED!!!");
    Debug.Log("LETS GET STARTED!!!");
    max = max + 1;
}

// Update is called once per frame
void Update()
{
    if (Input.GetKeyDown(KeyCode.UpArrow))
    {
        Debug.Log("Your number is biger then :" + guess);
        min = guess;
        guess = (max + min) / 2;
        Debug.Log("Is this the correct number?  " + guess);
    }
    else if (Input.GetKeyDown(KeyCode.DownArrow))
    {
        Debug.Log("Your number is lower then :" + guess);
        max = guess;
        guess = (max + min) / 2;
        Debug.Log("Is this the correct number?  " + guess);
    }
    else if(Input.GetKeyDown(KeyCode.Return))
    {
        Debug.Log("You press Enter, that means we found your number.");
        Debug.Log(guess + " This is the corrrect number.");
    }
}

}

2 Likes

Nice job! :slight_smile:

Nice clean code :slight_smile:

Privacy & Terms