using MoreLinq;
string[] cards = {"rock", "paper", "scissors"};
Dictionary<string, string> winningSituations = new Dictionary<string, string>
{
{"rock", "scissors"},
{"paper", "rock"},
{"scissors", "paper"}
};
Random random = new Random();
string botChoice = cards.Shuffle(random).First();
Console.WriteLine(botChoice);
Console.WriteLine("Enter your choice: (rock, paper, scissors)");
string userChoice = Console.ReadLine().ToLower();
if (!cards.Contains(userChoice))
{
Console.WriteLine("Invalid input!!!");
}
if (userChoice == botChoice)
{
Console.WriteLine("Draw!");
}else
{
switch (winningSituations[userChoice])
{
case botChoice:
Console.WriteLine("You Won the Round!");
break;
default:
Console.WriteLine("You Lost the Round!");
break;
}
}
using MoreLinq;
string[] cards = {"rock", "paper", "scissors"};
Dictionary<string, string> winningSituations = new Dictionary<string, string>
{
{"rock", "scissors"},
{"paper", "rock"},
{"scissors", "paper"}
};
Random random = new Random();
string botChoice = cards.Shuffle(random).First();
Console.WriteLine(botChoice);
Console.WriteLine("Enter your choice: (rock, paper, scissors)");
string userChoice = Console.ReadLine().ToLower();
if (!cards.Contains(userChoice))
{
Console.WriteLine("Invalid input!!!");
}
if (userChoice == botChoice)
{
Console.WriteLine("Draw!");
}else
{
switch (winningSituations[userChoice])
{
case botChoice:
Console.WriteLine("You Won the Round!");
break;
default:
Console.WriteLine("You Lost the Round!");
break;
}
}