C
C#6mo ago
HD-Fr0sT

How do i make these Readlines not interfere with each other

Its a menu and it has problems
No description
26 Replies
HD-Fr0sT
HD-Fr0sT6mo ago
Console.WriteLine("This is a menu test"); Console.WriteLine("there are (4) options"); Console.WriteLine(""); Console.WriteLine("Start (1) "); Console.WriteLine("Help (2) "); Console.WriteLine("Exit (3)"); //declaration string choice; do{ choice = Console.ReadLine();
if(choice == "1") {
Console.WriteLine("Yay start"); Console.WriteLine("say something"); string answer = Console.ReadLine(); Console.WriteLine(answer);
}

if(choice == "2") { Console.WriteLine("Do this"); }
if(choice == "3") { Console.WriteLine("Bye bye"); return; } else { Console.WriteLine("that was not an answer"); } }while (choice != "quit");
Jimmacle
Jimmacle6mo ago
what do you mean by interfere? also, $code
MODiX
MODiX6mo ago
To post C# code type the following: ```cs // code here ``` Get an example by typing $codegif in chat For longer snippets, use: https://paste.mod.gg/
HD-Fr0sT
HD-Fr0sT6mo ago
$code
MODiX
MODiX6mo ago
To post C# code type the following: ```cs // code here ``` Get an example by typing $codegif in chat For longer snippets, use: https://paste.mod.gg/ To post C# code type the following: ```cs // code here ``` Get an example by typing $codegif in chat For longer snippets, use: https://paste.mod.gg/
Jimmacle
Jimmacle6mo ago
just do what the text says
HD-Fr0sT
HD-Fr0sT6mo ago
Console.WriteLine("This is a menu test");
Console.WriteLine("there are (4) options");
Console.WriteLine("");
Console.WriteLine("Start (1) ");
Console.WriteLine("Help (2) ");
Console.WriteLine("Exit (3)");

//declaration
string choice;


do{

choice = Console.ReadLine();


if(choice == "1")
{

Console.WriteLine("Yay start");
Console.WriteLine("say something");
string answer = Console.ReadLine();
Console.WriteLine(answer);


}

if(choice == "2")
{
Console.WriteLine("Do this");
}

if(choice == "3")
{
Console.WriteLine("Bye bye");
return;
}

else
{
Console.WriteLine("that was not an answer");
}

}while (choice != "quit");
Console.WriteLine("This is a menu test");
Console.WriteLine("there are (4) options");
Console.WriteLine("");
Console.WriteLine("Start (1) ");
Console.WriteLine("Help (2) ");
Console.WriteLine("Exit (3)");

//declaration
string choice;


do{

choice = Console.ReadLine();


if(choice == "1")
{

Console.WriteLine("Yay start");
Console.WriteLine("say something");
string answer = Console.ReadLine();
Console.WriteLine(answer);


}

if(choice == "2")
{
Console.WriteLine("Do this");
}

if(choice == "3")
{
Console.WriteLine("Bye bye");
return;
}

else
{
Console.WriteLine("that was not an answer");
}

}while (choice != "quit");
ile show the terminal output
Angius
Angius6mo ago
?
HD-Fr0sT
HD-Fr0sT6mo ago
No description
Jimmacle
Jimmacle6mo ago
your problem isn't the readlines your problem is the logic in your loop wait i got thrown off by your spacing i mean, they're not interfering with each other because that's not a thing that can happen
HD-Fr0sT
HD-Fr0sT6mo ago
i mean they are active at the same time
Jimmacle
Jimmacle6mo ago
what does "active" mean?
HD-Fr0sT
HD-Fr0sT6mo ago
i mean the else else { Console.WriteLine("that was not an answer"); }
Jimmacle
Jimmacle6mo ago
okay, so look at all your if statements follow the logic in your code
HD-Fr0sT
HD-Fr0sT6mo ago
they are all in the same lane
Jimmacle
Jimmacle6mo ago
"lane?"
HD-Fr0sT
HD-Fr0sT6mo ago
level i think im thinking too pythonically
Jimmacle
Jimmacle6mo ago
which is actually your problem you have 3 independent if statements
HD-Fr0sT
HD-Fr0sT6mo ago
when i give an answer to the string read it also gets picked up by the first choice variable
Jimmacle
Jimmacle6mo ago
you are making bad assumptions $debug and check if what you're saying is true
MODiX
MODiX6mo ago
Tutorial: Debug C# code and inspect data - Visual Studio (Windows)
Learn features of the Visual Studio debugger and how to start the debugger, step through code, and inspect data in a C# application.
Angius
Angius6mo ago
Hint: else if
Jimmacle
Jimmacle6mo ago
i was trying to get them to think a little more methodically when is a good skill to have
HD-Fr0sT
HD-Fr0sT6mo ago
should do like elif or an else with a if inside i
Angius
Angius6mo ago
Try and see Hint: hint
Jimmacle
Jimmacle6mo ago
when
Want results from more Discord servers?
Add your server
More Posts