C# 如何揭示选择
写一个非常简单的石头剪刀布游戏。我需要它来显示计算机的选择,这样用户在做出选择之前就知道了。我还需要关闭循环中的区分大小写功能。有人能帮我吗C# 如何揭示选择,c#,C#,写一个非常简单的石头剪刀布游戏。我需要它来显示计算机的选择,这样用户在做出选择之前就知道了。我还需要关闭循环中的区分大小写功能。有人能帮我吗 namespace m4 { class Program { static void Main(string[] args) { do { Random r = new Random(); int Player1C
namespace m4
{
class Program
{
static void Main(string[] args)
{
do
{
Random r = new Random();
int Player1Choice = r.Next(4);
Console.WriteLine("Player 1 chose ");
string Player1Choice = Console.ReadLine();
Console.WriteLine("Player 2, do you choose rock,paper or scissors");
string Player2Choice = Console.ReadLine();
if (Player1Choice == "1")
{
if (Player2Choice == "rock")
{
Console.WriteLine("Both players chose rock");
Console.WriteLine("It is a tie ");
}
else if (Player2Choice == "paper")
{
Console.WriteLine("Player 1 chose rock, Player 2 chose paper");
Console.WriteLine("Player 2 wins!");
}
else if (Player2Choice == "scissors")
{
Console.WriteLine("Player 1 chose rock, Player 2 chose scissors");
Console.WriteLine("Player 1 wins! ");
}
else
{
Console.WriteLine("You must choose rock,paper or scissors!");
}
}
else if (Player1Choice == "2")
{
if (Player2Choice == "rock")
{
Console.WriteLine("Player 1 chose paper, Player 2 chose rock");
Console.WriteLine("Player 1 wins!");
}
else if (Player2Choice == "paper")
{
Console.WriteLine("Both players chose paper");
Console.WriteLine("It is a tie! ");
}
else if (Player2Choice == "scissors")
{
Console.WriteLine("Player 1 chose paper, Player 2 chose scissors");
Console.WriteLine("Player 2 wins!");
}
else
{
Console.WriteLine("You must choose rock,paper or scissors!");
}
}
else if (Player1Choice == "3")
{
if (Player2Choice == "rock")
{
Console.WriteLine("Player 1 chose scissors, Player 2 chose rock");
Console.WriteLine("Player 2 wins!");
}
else if (Player2Choice == "paper")
{
Console.WriteLine("Player 1 chose scissors, Player 2 chose paper");
Console.WriteLine("Player 1 wins!");
}
else if (Player2Choice == "scissors")
{
Console.WriteLine("Both players chose scissors");
Console.WriteLine("It is a tie!");
}
else
{
Console.WriteLine("You must choose rock,paper or scissors!");
}
Console.WriteLine("Would you like to play again?");
}
} while (Console.ReadLine() == "yes");
}
}
}
好的,我似乎已经把它的大部分都弄明白了,在我编译它之前我不会确定。现在,我在编译这行代码时不断收到cs0019错误:while(Console.ReadLine().ToLower().ToUpper()=“yes”);这是我循环的结束,它需要不区分大小写,只是在正确的语法中有问题。很抱歉前面的评论,错误在另一行。好的,我一直在做这件事,现在似乎我得到了一个错误,这不是发生在原来的编码。因为我已经拿出了原来的播放器1并把它们变成了电脑,我的播放器1选择==行现在被确定为错误,我不知道为什么。该死,修复了这个问题。让它编译,循环和不区分大小写都在工作,计算机选择它,玩家选择他们的。然而,在玩家2选择他们的选择之前,计算机的选择并没有被透露出来,它也没有询问他们是否想再玩一次。另外一个问题解决了,另一个问题出现了。我已经解决了之前的所有问题,但我仍然并没有弄清楚如何让它说是计算机选择的(石头剪刀),而不是计算机选择的整数