This is Hard. Someone please help!

Did you see any problem here ? if you did can you notify me please and tell me the solution to it. It will be a great help .

Hi,

Could you copy/paste your code into your post instead of using the screenshot, it is quite difficult to read. It also prevents people who offer to help you from copy/pasting parts of your code back to you with suggestions/corrections. Please also apply the code formatting characters before and after it.

With the full script visible it may be possible to identify your error, but as you have code collapsed in your screenshot(s), a mixture of indenting and haven’t given any indication as to the error message you may be receiving it’s quite hard to diagnose.

Help us, help you :slight_smile:


See also;

So here is my code. I hope you can help me with it.I can’t move foward without solving this first.

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

public class Hacker : MonoBehaviour
{   
    //Game State
    int level;
    enum Screen { MainMenu, Password, Win }
    Screen curentScreen = Screen.MainMenu;
    Screen CurrentScreen;
    string password;
    public string Password { get; private set; }

    // Use this for initialization
    void Start()
    {
        print("Hello" + "World");
        ShowMainMenu();
    }

    void ShowMainMenu()
    {
        CurrentScreen = Screen.MainMenu;

        Terminal.ClearScreen();
        Terminal.WriteLine("Which Terminal You Want To Hack");
        Terminal.WriteLine("Press 1 To Hack School");
        Terminal.WriteLine("Press 2 To Hack Police Station");
        Terminal.WriteLine("Enter Your Selection:");
    }

    void OnUserInput(string input)
    {
        if (input == "menu")
        {
            ShowMainMenu();
        }
        else if (CurrentScreen == Screen.MainMenu)
        {
            RunMainMenu(input);
        }
        else if (CurrentScreen == Screen.Password)
        {
            CheckPassword(input);
        }

        void RunMainMenu(string input);
        {
            if (input == "1")
            {
                level = 1;
                Password = "donkey";
                StartGame();
            }
            else if (input == "2")
            {
                level = 2;
                Password = "combobulate";
                StartGame();
            }
            else if (input == "1474")
            {
                Terminal.WriteLine("Please Enter Your Level, Develepor");
            }
            else
            {
                Terminal.WriteLine("Please Choose A Valid Level");
            }
        }

        void StartGame()
        {
            CurrentScreen = Screen.Password;
            Terminal.WriteLine("You Have Chosen Level " + level);
            Terminal.WriteLine("Please Enter Your Password");
        }

        void CheckPassword(string input);
        {
            if (input == Password)
            {
                Terminal.WriteLine("WELL DONE!");
            }
        }
        else
        {
            Terminal.WriteLine("Sorry,Wrong Password");
        }
    }

}

Just looking it over at a quick glance and I noticed:

public string Password { get; private set; }

If your trying to define it as a variable it should be:

string Password;

Not sure what you were trying to accomplish with that line of code - why do you have {} and why are you using getters and setters?

Hi,

You have a missing closing curly brace at the end of the OnUserInput method, as such the following methods have become nested. You then have an additional closing curly brace in the CheckPassword method before the else statement.

Note, it’s really difficult for others to read your code if you don’t make a little effort to tidy it up/format it in a way that is readable on the forum. Possibly because you emailed a response in, the code had double line spacing, no indentation and you hadn’t added the code formatting characters which I provided information about in my earlier post. You are much more likely to get responses, and quickly, from people if it is easier to read your post.

Hope this helps.

Dear Rob,
That really help me a lot.Now I can continue on the course.

I Apreciate your help so much.Thank you and Have a nice weekend


Virus-free. www.avast.com

1 Like

You’re very welcome, happy to help. :slight_smile:

Privacy & Terms