Challenge - Local Greetings

using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;
using UnityEditorInternal;
using UnityEngine;

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

    // Use this for initialization
    void Start()
    {
        Debug.Log("Welcome to the Magic Number Guesser.");
        Debug.Log("Pick a number between " + min + " and " + max);
        
        Debug.Log("...");
        Debug.Log("...");
        Debug.Log("...");
        Debug.Log("...");
        Debug.Log("...");
        Debug.Log("...");
        Debug.Log("...");
        Debug.Log("...");
        Debug.Log("...");
        Debug.Log("...");
        
        
        
        Debug.Log("Is the number you picked higher or lower than " + guess);
        
        Debug.Log("...");
        
        Debug.Log("Hit the UP Arrow if your number is higher then my guess, Hit the Down Arrow if your number is lower, Hit enter if I got it right.");
        max = max + 1;
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            Debug.Log("Oh, your number is higher than " + guess + ".");
            min = guess;
            guess = (max + min) / 2;
            Debug.Log("...");
            Debug.Log("Let me try again. Is your number.....  " + guess);
        }

        else if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            Debug.Log("Ah, so your number is lower than " + guess + ".");
            max = guess;
            guess = (max + min) / 2;
            Debug.Log("..."); 
            Debug.Log("Hm, let me see, is your number.....  " + guess);
        }

        else if (Input.GetKeyDown(KeyCode.Return))
        {
            Debug.Log("Hey, I got it right, told you I was magic.");
        }
    }
}

Privacy & Terms