我不知道为什么在我添加最后一条if
语句后,我得到了这个错误。我的代码运行良好,但在添加后if
我得到了这个错误。如果您能帮我解决这个问题,我将不胜感激。
string answer = Console.ReadLine();
if (answer == "cold" || answer == "a cold")
{
Console.WriteLine("Well done you may pass");
Console.WriteLine("Doors are now Open");
Console.ReadLine();
}
else if (selection == "W" ||selection == "w" && answer != "cold" || answer != "a cold")
{
characterHealth = characterHealth - 20;
Console.WriteLine("Wrong Answer Try Again");
Console.WriteLine("Your health level is: {0}", characterHealth);
Console.ReadLine();
}
else if (selection == "S" || selection == "s" && answer != "cold" || answer != "a cold")
{
characterHealth = characterHealth - 10;
Console.WriteLine("Wrong Answer Try Again");
Console.WriteLine("Your health level is: {0}", characterHealth);
Console.ReadLine();
}
}
int dragonHealth = 150;
int strike = randomNumbers.Next(1, 30);
int strike1 = randomNumbers.Next(1, 50);
Console.Writeline("As you move on you are encountering a small dragon");
while (dragonHealth >= 0 && characterHealth >= 0)
{
dragonHealth = dragonHealth - strike1;
characterHealth = characterHealth - strike;
Console.WriteLine("You strike the dragon, its health is: {0}", dragonHealth);
Console.WriteLine("The dragon counters, your health is: {0}", characterHealth);
if ( characterHealth >= 0 && dragonHealth <= 0)
{
Console.WriteLine("Congratulations you have killed the dragon");
Console.WriteLine("You found the tresure, Story ends here");
Console.ReadLine();
}
if ( characterHealth <= 0 && dragonHealth >=0)
{
Console.WriteLine("You died Game over");
return;
}
if ( characterHealth <= 0 && dragonHealth <=0)
{
Console.WriteLine("You both died at the same time bad luck");
return;
}
Console.ReadLine();