Код: Выделить всё
using System.ComponentModel.Design;
using System.Runtime.CompilerServices;
Random random = new Random();
bool playagain = true;
String player = "";
int computer = random.Next(1,4);
Console.WriteLine("Enter, ROCK,PAPER,SCISSORS : ");
player = Console.ReadLine();
player.ToUpper();
while (playagain)
{
while (player != "ROCK" && player != "PAPER" && player != "SCISSORS")
{
Console.WriteLine("Enter, ROCK,PAPER,SCISSORS : ");
player = Console.ReadLine();
player.ToUpper();
}
switch (computer) {
case 1:// computer = rock
if (player.Equals("ROCK"))
{
Console.WriteLine("Computer : Rock");
Console.WriteLine("It's a tie !");
}
else if (player.Equals("PAPER"))
{
Console.WriteLine("Computer : ROCK");
Console.WriteLine("You lose !");
}
else {
Console.WriteLine("Computer : SCISSORS");
Console.WriteLine("You win !");
}
break;
case 2:// computer = paper
if (player.Equals("ROCK"))
{
Console.WriteLine("Computer : PAPER");
Console.WriteLine("You lose !");
}
else if (player.Equals("PAPER"))
{
Console.WriteLine("Computer : PAPER");
Console.WriteLine("It's a tie !");
}
else// player = scissors
{
Console.WriteLine("Computer : PAPER");
Console.WriteLine("You win !");
}
break;
case 3: // computer = scissors
if (player.Equals("ROCK"))
{
Console.WriteLine("Computer : SCISSORS");
Console.WriteLine("You win !");
}
else if (player.Equals("PAPER"))
{
Console.WriteLine("Computer : SCISSORS");
Console.WriteLine("You lose !");
}
else // player = scissors
{
Console.WriteLine("Computer : SCISSORS");
Console.WriteLine("It's a tie !");
}
break;
}
}
Может ли кто -нибудь объяснить мне, что не так с моим кодом выше? изменилось, это очень странно.
Подробнее здесь: https://stackoverflow.com/questions/767 ... ssors-game