C#

Rock-Paper-Scissor Game in C Sharp

0

using System;

public class HelloWorld

{

    public static void Main(string[] args)

    {

        // Game Start

        Console.WriteLine (“Let’s Play Rock Paper Scissor “);

        while(true){

        Console.Write(“Choice your Role : “);

        // User Input

        string yourRole = Console.ReadLine().ToLower();

        Console.WriteLine(“Your Role : “+yourRole);

        // Computer Random Design by Random Number 

        Random rand = new Random();

        int random = rand.Next(0,3);

        string[] comRole = {“Rock”,”Paper”,”Scissor”};

        Console.WriteLine(“Computer Role : “+comRole[random]+”\n”);

        

        if(yourRole == “rock”){

            if(comRole[random] == “Rock”){

                Console.WriteLine(“TIE😒”);

            }

            else if(comRole[random] == “Scissor”){

                  Console.WriteLine(“Congratulation !  You Won 🍾🍾”);

            }

            else{

                  Console.WriteLine(“Haha !  You Lose😂”);

            }

            break;

        }

        else if(yourRole == “scissor”){

            if(comRole[random] == “Rock”){

                  Console.WriteLine(“Haha !  You Lose😂”);

            }

            else if(comRole[random] == “Scissor”){

                Console.WriteLine(“TIE😒”);

            }

            else{

                  Console.WriteLine(“Congratulation !  You Won 🍾🍾”);

            }

            break;

        }

        else if(yourRole == “paper”){

            if(comRole[random] == “Rock”){

                  Console.WriteLine(“Congratulation !  You Won 🍾🍾”);

            }

            else if(comRole[random] == “Scissor”){

                  Console.WriteLine(“Haha !  You Lose😂”);

            }

            else{

                Console.WriteLine(“TIE😒”);

            }

            break;

        }

        else{

              Console.WriteLine(“INVALID INPUT : you enter wrong role.”);

              Console.Write(“Again : “);

        }

        }

    }

}

rIjan Tamang
WRITTEN BY

rIjan Tamang

Website is working : rijan.tiiny.site

Leave a Reply

Your email address will not be published. Required fields are marked *