C#C
C#3y ago
Ronnie

✅ rock paper scissors game

// beginner project - rock, paper scissors game

using System;
using System.Collections.Generic;

namespace RockPaperScissors
{
    class Program
    {
        static void Main(string[] args )
        {
            Console.WriteLine("Welcome to my rock paper scissors game!");

            string[] choice = { "Rock", "Paper", "Scissors" };


            int round = 0;

            // counters here help to keep track of the amount of points the player and the computer have 
            int PointsUser = 0;
            int PointsComp = 0;


            while (round < 3) // best out of three 
            {
                Random rand = new Random();
                int index = rand.Next(choice.Length);

                var CompChoice = choice[index];

                Console.WriteLine("Choose your element: ");
                string UserInput = Console.ReadLine();


                if (UserInput == "Rock") && (CompChoice == "Paper")
                 {
                    Console.WriteLine("Round 1 goes to the user");
                    round++;
                    PointsUser++;
                }
            }

        }
    }
}

I'm getting an error with the if statement, says that && is invalid
Was this page helpful?