爲什麼每次我有第二個if/else if
聲明時,我必須輸入任何第二個if
條件,兩次?幾乎就像它給了我2個readlines方法()由於某種原因幾乎就像「else if語句」給我2 ReadLines()如果用戶鍵入第二個或第三個選項
//Directions (Actions) You May Take:
public string forward = "forward";
public string back = "back";
public string left = "left";
public string right = "right";
public void closet()
{
Console.WriteLine("You open the door at the top of the basement staircase and it leads to what appears to be a closet?");
Console.WriteLine("You can feel random clutter but it's still so dark. There is another door in front of you...");
Console.WriteLine("Only 2 directions you can take. [BACK] or [FORWARD]");
if (forward == Console.ReadLine())
{
hallway();
}
if (back == Console.ReadLine())
{
Console.WriteLine("The door behind you to the basement is now locked... weird...");
}
else
{
Console.WriteLine(wrong);
}
}
public void hallway()
{
Console.WriteLine("\nYou open the door in front of you and crawl out into what appears to be a hallway.");
Console.WriteLine("There are 3 direcitons you can take. [BACK] or [LEFT] or [RIGHT]");
Console.WriteLine("What direction do you take?");
if (left == Console.ReadLine())
{
bathroom();
}
if (right == Console.ReadLine())
{
livingroom();
}
else
{
Console.WriteLine(wrong);
}
}
public void bathroom()
{
Console.WriteLine("This is the bathroom");
}
public void livingroom()
{
Console.WriteLine("This is the livingroom");
}
我多次閱讀你的問題。但是找不到你正在問的關於 –