C#C
C#3y ago
Ryan-T1412

❔ ✅ error CS0150 A constant value is expected

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;
    }
}
image.png
Was this page helpful?