Choose Your Own Adventure

When I put in this command into the bash
yes
It comes out as
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
and so on
And when I put in this command: YES
It comes out as:
bash: Command not found.

This is my code if you need to know what I have to change:
using System;

namespace ChooseYourOwnAdventure
{
class Program
{
static void Main(string args)
{
/* THE MYSTERIOUS NOISE */

  // Start by asking for the user's name:
  Console.Write("What is your name?: ");
  string name = Console.ReadLine();
  Console.WriteLine($"Hello, {name}! Welcome to our story.");
  Console.WriteLine("It begins on a cold rainy night.");
  Console.WriteLine("You're sitting in your room and hear a noise coming from down the hall.");
  Console.WriteLine("Do you go investigate?");
  Console.Write("Type YES or NO: ");
  string word = "yes";
  string noiseChoice = word.ToUpper();
}

}
}

After Console.Write("Type YES or NO: "): you need a Console.ReadLine() in order to get the user’s input. Something like this:

Console.Write("Type YES or NO: ");
string noiseChoice = Console.ReadLine().ToUpper(); //you can chain the methods

Without the Console.ReadLine(), the console isn’t waiting for a response from you, so you are typing commands straight into the bash console.

Thanks a million mate.

1 Like

I now have another problem.
When I put in the commands yes, YES, no and NO, I get nothing.
This is the code:
using System;

namespace ChooseYourOwnAdventure
{
class Program
{
static void Main(string args)
{
/* THE MYSTERIOUS NOISE */

  // Start by asking for the user's name:
  Console.Write("What is your name?: ");
  string name = Console.ReadLine();
  Console.WriteLine($"Hello, {name}! Welcome to our story.");
  Console.WriteLine("It begins on a cold rainy night.");
  Console.WriteLine("You're sitting in your room and hear a noise coming from down the hall.");
  Console.WriteLine("Do you go investigate?");
  Console.Write("Type YES or NO: ");
  string noiseChoice = Console.ReadLine().ToUpper();
  string firstChoice = Console.ReadLine();
    if (firstChoice == "NO")
    {
      Console.WriteLine("Not much of an adventure if we don't leave our room!");
      Console.WriteLine("THE END.");
    }
    else if (firstChoice == "YES")
    {
      Console.WriteLine("You walk into the hallway and see a light coming from under a door down the hall.");
      Console.WriteLine("You walk towards it. Do you open it or knock?");
    }
  Console.Write("Type OPEN or KNOCK: ");
  string doorChoice = Console.ReadLine().ToUpper();
}

}
}

You assigned the user’s input to noiseChoice already. This line string firstChoice = Console.ReadLine(); is expecting what exactly?
Your if() statements need to use the same variable that the user’s input was assigned to which was noiseChoice. If you’d rather call the variable firstChoice, you need to change the original assignment from the user’s input to firstChoice as well. Hopefully that made sense.

Thanks. I’m starting to think of trusting you rather than trusting the hints that I get.

1 Like

A lot of times the ‘hints’ give us a general idea of how to complete the step, but not the exact code. Look to the instructions for things like variable names and other specifics. Use the hints if you aren’t sure what to do, or how to do it, but don’t copy them exactly. Occasionally the hint will provide an exact solution, but usually it’s more of a pattern to follow.