I am coding a text adventure and I have a problem. I am trying to make a switch statement that processes every required examination action, and I get this for my code:
case "examine" + string x: //this is a method that I made that makes sure that it is an object in the area bool iseobj = tut.Check(x); if (iseobj) x.examine(); else Console.WriteLine("That isn't an object to examine"); break;
How to use a variable in my instruction case? I want any line to start with "check" + (x) to trigger this case.
case
if-else , switch. # a switch , . , :
if-else
switch
case input.StartsWith("examine"):
if! :
if
if (input.StartsWith("examine")) { //this is a method that I made that makes sure that it is an object in the area bool iseobj = tut.Check(x); if (iseobj) x.examine(); else Console.WriteLine("That isn't an object to examine"); } else if (...) // other branches here