static void Main(string[] args)
        {
            string InputPlayer, InputCPU;
            int    scoreCPU = 0, scorePlayer = 0;
            bool   loop = true;
            int    keep = 1;

            while (keep == 1)
            {
                Console.Write("Pedra , Papel ou tesoura ? : ");
                InputPlayer = Console.ReadLine();
                InputPlayer = InputPlayer.ToUpper();


                Random rndnumber      = new Random();
                int    RandomCPUInput = rndnumber.Next(1, 4);

                switch (RandomCPUInput)
                {
                case 1:
                {
                    InputCPU = "PEDRA";
                    InputCPU = InputCPU.ToUpper();

                    if (InputCPU == InputPlayer)
                    {
                        Console.WriteLine("EMPATE !!");
                        Console.WriteLine("O computador escolheu Pedra");
                        Console.WriteLine("Sua Pontuação : " + scorePlayer + " Computador : " + scoreCPU);
                    }

                    else if (InputPlayer == "PAPEL")
                    {
                        Console.WriteLine("GANHASTE !");
                        Console.WriteLine("O computador escolheu Pedra");
                        scorePlayer++;

                        Console.WriteLine("Sua Pontuação : " + scorePlayer + " Computador : " + scoreCPU);
                    }

                    else if (InputPlayer == "TESOURA")
                    {
                        Console.WriteLine("PERDEU MANO !");
                        Console.WriteLine("O computador escolheu Pedra");
                        scoreCPU++;

                        Console.WriteLine("Sua Pontuação : " + scorePlayer + " Computador : " + scoreCPU);
                    }
                    break;
                }

                case 2:
                {
                    InputCPU = "PAPEL";
                    InputCPU = InputCPU.ToUpper();

                    if (InputCPU == InputPlayer)
                    {
                        Console.WriteLine("EMPATE !!");
                        Console.WriteLine("O computador escolheu Papel");
                        Console.WriteLine("Sua Pontuação : " + scorePlayer + " Computador : " + scoreCPU);
                    }

                    else if (InputPlayer == "TESOURA")
                    {
                        Console.WriteLine("GANHASTE !");
                        Console.WriteLine("O computador escolheu Papel");
                        scorePlayer++;

                        Console.WriteLine("Sua Pontuação : " + scorePlayer + " Computador : " + scoreCPU);
                    }

                    else if (InputPlayer == "PEDRA")
                    {
                        Console.WriteLine("PERDEU MANO !");
                        Console.WriteLine("O computador escolheu Papel");
                        scoreCPU++;

                        Console.WriteLine("Sua Pontuação : " + scorePlayer + " Computador : " + scoreCPU);
                    }
                    break;
                }

                case 3:
                {
                    InputCPU = "TESOURA";
                    InputCPU = InputCPU.ToUpper();

                    if (InputCPU == InputPlayer)
                    {
                        Console.WriteLine("EMPATE !!");
                        Console.WriteLine("O computador escolheu Tesoura");
                        Console.WriteLine("Sua Pontuação : " + scorePlayer + " Computador : " + scoreCPU);
                    }

                    else if (InputPlayer == "PAPEL")
                    {
                        Console.WriteLine("PERDEU MANO !");
                        Console.WriteLine("O computador escolheu Tesoura");
                        scoreCPU++;

                        Console.WriteLine("Sua Pontuação : " + scorePlayer + " Computador : " + scoreCPU);
                    }

                    else if (InputPlayer == "PEDRA")
                    {
                        Console.WriteLine("GANHASTE !");
                        Console.WriteLine("O computador escolheu Tesoura");
                        scorePlayer++;

                        Console.WriteLine("Sua Pontuação : " + scorePlayer + " Computador : " + scoreCPU);
                    }
                    break;
                }
                }
                Console.WriteLine("Quer continuar jogando / 1- sim / 2- nao : \n\n\n");
                keep = Convert.ToInt32(Console.ReadLine());

                if (keep == 2)
                {
                    break;
                }
            }
            Console.ReadKey();
        }
示例#2
0
        static void Main(string[] args)
        {
            string InputPlayer, inputCPU;
            int    randomInt;

            bool playAgain = true;

            while (playAgain)
            {
                int scorePlayer = 0;
                int scoreCPU    = 0;

                while (scorePlayer < 3 && scoreCPU < 3)
                {
                    Console.WriteLine("Choose between Rock, Paper and Scissors:  ");
                    InputPlayer = Console.ReadLine();
                    InputPlayer = InputPlayer.ToUpper();

                    Random rnd = new Random();
                    randomInt = rnd.Next(1, 4);

                    switch (randomInt)
                    {
                    case 1:
                        inputCPU = "ROCK";
                        Console.WriteLine("Computer chose ROCK");
                        if (InputPlayer == "ROCK")
                        {
                            Console.WriteLine("DRAW!!\n\n");
                        }
                        else if (InputPlayer == "PAPER")
                        {
                            Console.WriteLine("PLAYER WINS!!\n\n");
                            scorePlayer++;
                        }
                        else if (InputPlayer == "SCISSORS")
                        {
                            Console.WriteLine("COMPUTER WINS!!\n\n");
                            scoreCPU++;
                        }
                        break;

                    case 2:
                        inputCPU = "PAPER";
                        Console.WriteLine("Computer chose PAPER");
                        if (InputPlayer == "PAPER")
                        {
                            Console.WriteLine("DRAW!!\n\n");
                        }
                        else if (InputPlayer == "ROCK")
                        {
                            Console.WriteLine("COMPUTER WINS!!\n\n");
                            scoreCPU++;
                        }
                        else if (InputPlayer == "SCISSORS")
                        {
                            Console.WriteLine("PLAYER WINS!!\n\n");
                            scorePlayer++;
                        }
                        break;

                    case 3:
                        inputCPU = "SCISSORS";
                        Console.WriteLine("Computer chose SCISSORS");
                        if (InputPlayer == "SCISSORS")
                        {
                            Console.WriteLine("DRAW!!\n\n");
                        }
                        else if (InputPlayer == "PAPER")
                        {
                            Console.WriteLine("COMPUTER WINS!!\n\n");
                            scoreCPU++;
                        }
                        else if (InputPlayer == "ROCK")
                        {
                            Console.WriteLine("PLAYER WINS!!\n\n");
                            scorePlayer++;
                        }
                        break;

                    default:
                        Console.Write("Invaid Entry");
                        break;
                    }

                    Console.WriteLine("\n\nSCORES:\tPLAYER:\t{0}\tCPU:\t{1}", scorePlayer, scoreCPU);
                }

                if (scorePlayer == 3)
                {
                    Console.WriteLine("PLAYER WON!");
                }
                else if (scoreCPU == 3)
                {
                    Console.WriteLine("COMPUTER WON!");
                }
                else
                {
                }
                Console.WriteLine("Do you want to play again? Y/N");
                string loop = Console.ReadLine();
                loop = loop.ToUpper();

                if (loop == "Y")
                {
                    playAgain = true;
                    Console.Clear();
                }
                else if (loop == "N")
                {
                    playAgain = false;
                }
            }
        }
示例#3
0
        static void SinglePlayer(string[] args)
        {
            string InputPlayer, InputCPU;
            int    randomInt;
            bool   playAgain = true;

            while (playAgain)
            {
                int scorePlayer = 0;
                int scoreCPU    = 0;

                while (scorePlayer < 3 && scoreCPU < 3)
                {
                    Console.WriteLine("Choose between Rock,Paper,Scissor,Spock,Lizard:    ");
                    InputPlayer = Console.ReadLine();
                    InputPlayer = InputPlayer.ToUpper();
                    Random rnd = new Random();

                    randomInt = rnd.Next(1, 6);
                    switch (randomInt)
                    {
                    case 1:
                        InputCPU = "Rock";
                        Console.WriteLine("Computer chose Rock");
                        if (InputPlayer == "Rock")
                        {
                            Console.WriteLine("Draw!!\n\n");
                        }
                        else if (InputPlayer == "Paper")
                        {
                            Console.WriteLine("Player Wins!!\n\n");
                            scorePlayer++;
                        }
                        else if (InputPlayer == "Scissor")
                        {
                            ;
                        }
                        {
                            Console.WriteLine("CPU WINS!!\n\n");
                            scoreCPU++;
                        }
                        break;

                    case 2:
                        InputCPU = "Paper";
                        Console.WriteLine("Computer chose Paper");
                        if (InputPlayer == "Paper")
                        {
                            Console.WriteLine("Draw!!\n\n");
                        }
                        else if (InputPlayer == "Scissor")
                        {
                            Console.WriteLine("Player Wins!!\n\n");
                            scorePlayer++;
                        }
                        else if (InputPlayer == "Rock")
                        {
                            ;
                        }
                        {
                            Console.WriteLine("CPU WINS!!\n\n");
                            scoreCPU++;
                        }
                        break;

                    case 3:
                        InputCPU = "Scissors";
                        Console.WriteLine("Computer chose Scissor");
                        if (InputPlayer == "Scissor")
                        {
                            Console.WriteLine("Draw!!\n\n");
                        }
                        else if (InputPlayer == "Spock")
                        {
                            Console.WriteLine("Player Wins!!\n\n");
                            scorePlayer++;
                        }
                        else if (InputPlayer == "Paper")
                        {
                            ;
                        }
                        {
                            Console.WriteLine("CPU WINS!!\n\n");
                            scoreCPU++;
                        }
                        break;

                    case 4:
                        InputCPU = "Spock";
                        Console.WriteLine("Computer chose Spock");
                        if (InputPlayer == "Spock")
                        {
                            Console.WriteLine("Draw!!\n\n");
                        }
                        else if (InputPlayer == "Lizard")
                        {
                            Console.WriteLine("Player Wins!!\n\n");
                            scorePlayer++;
                        }
                        else if (InputPlayer == "Scissor")
                        {
                            ;
                        }
                        {
                            Console.WriteLine("CPU WINS!!\n\n");
                            scoreCPU++;
                        }
                        break;

                    case 5:
                        InputCPU = "Lizard";
                        Console.WriteLine("Computer chose Lizard");
                        if (InputPlayer == "Lizard")
                        {
                            Console.WriteLine("Draw!!\n\n");
                        }
                        else if (InputPlayer == "Rock")
                        {
                            Console.WriteLine("Player Wins!!\n\n");
                            scorePlayer++;
                        }
                        else if (InputPlayer == "Spock")
                        {
                            ;
                        }
                        {
                            Console.WriteLine("CPU WINS!!\n\n");
                            scoreCPU++;
                        }
                        break;
                        Console.ReadLine();

                    default:
                        Console.WriteLine("Invaild Entry");
                        break;
                    }
                    Console.WriteLine("\n\nScores:\tPlayer\t{0}", scorePlayer, scoreCPU);
                }
                if (scorePlayer == 2)
                {
                    Console.WriteLine("Player Won!");
                }
                else if (scoreCPU == 2)
                {
                    Console.WriteLine("CPU WON!");
                }
                Console.WriteLine("Do you want to play again?(yes/no)");
                string loop = Console.ReadLine();
                if (loop == "yes")
                {
                    playAgain = true;
                    Console.Clear();
                }
                else if (loop == "no")
                {
                    playAgain = false;
                }
                else
                {
                }
            }
        }