Rock Paper Scissors for MLH Beginner Week

using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;
using System.Threading;


namespace Rock_Paper_Scissors
{
    internal class Program
    {
        static void Main(string[] args)
        {
            int wins = 0;
            int losses = 0;
            int ties = 0;
            bool isRunning = true;
            while(isRunning)
            {
                Console.WriteLine("\n");
                //prompt for rock paper or scissors
                Console.WriteLine("Please select Rock(R) Paper(P) or Scissors(S)");
                Console.WriteLine("You can also quit by saying \"Quit\"");
                string selection = Console.ReadLine().ToUpper();
                if(selection == "QUIT")
                {
                    break;
                }
                while (selection != "R" && selection != "P" && selection != "S") 
                {
                    Console.WriteLine("Invalid Selection");
                    Console.WriteLine("Please select Rock(R) Paper(P) or Scissors(S)");
                    selection = Console.ReadLine().ToUpper();
                }

                Console.Write("Advanced AI is now deciding a move");
               for(int i = 0; i < 5; i++)
                {
                    Console.Write(".");
                    Thread.Sleep(250); 
                }

                //pick a random number between 1 and 3
                Random rand = new Random();
                int aiSelection = rand.Next(1, 4);
                //1 = rock
                //2 = paper
                //3 = scissors
                //compare the user selection to the ai selection
                if (selection == "R")
                {
                    if (aiSelection == 1)
                    {
                        Console.WriteLine("You both selected Rock, it's a tie!");
                        ties++;
                    }
                    else if (aiSelection == 2)
                    {
                        Console.WriteLine("You selected Rock, the AI selected Paper, you lose!");
                        losses++;
                    }
                    else if (aiSelection == 3)
                    {
                        Console.WriteLine("You selected Rock, the AI selected Scissors, you win!");
                        wins++;
                    }
                }
                else if (selection == "P")
                {
                    if (aiSelection == 1)
                    {
                        Console.WriteLine("You selected Paper, the AI selected Rock, you win!");
                        wins++;
                    }
                    else if (aiSelection == 2)
                    {
                        Console.WriteLine("You both selected Paper, it's a tie!");
                        ties++;
                    }
                    else if (aiSelection == 3)
                    {
                        Console.WriteLine("You selected Paper, the AI selected Scissors, you lose!");
                        losses++;
                    }
                }
                else if (selection == "S")
                {
                    if (aiSelection == 1)
                    {
                        Console.WriteLine("You selected Scissors, the AI selected Rock, you lose!");
                        losses++;
                    }
                    else if (aiSelection == 2)
                    {
                        Console.WriteLine("You selected Scissors, the AI selected Paper, you win!");
                        wins++;
                    }
                    else if (aiSelection == 3)
                    {
                        Console.WriteLine("You both selected Scissors, it's a tie!");
                        ties++;
                    }
                }

                Console.WriteLine("Your Wins: " + wins);
                Console.WriteLine("Your Losses: " + losses);
                Console.WriteLine("Your Ties: " + ties);
            }

            Console.WriteLine("Thanks for playing!");
        }
    }
}

Built With

Share this project:

Updates