Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Saw
- {
- class Program
- {
- static Random rnd = new Random();
- 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.Write("Choose between ROCK, PAPER and SCISSORS: ");
- inputPlayer = Console.ReadLine().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("CPU WINS!!\n\n");
- scoreCpu++;
- }
- break;
- case 2:
- inputCPU = "PAPER";
- Console.WriteLine("Computer chose PAPER");
- if (inputPlayer == "ROCK")
- {
- Console.WriteLine("CPU WINS!!\n\n");
- scoreCpu++;
- }
- else if (inputPlayer == "PAPER")
- {
- Console.WriteLine("DRAW!!\n\n");
- }
- else if (inputPlayer == "SCISSORS")
- {
- Console.WriteLine("PLAYER WINS!!\n\n");
- scorePlayer++;
- }
- break;
- case 3:
- inputCPU = "SCISSORS";
- Console.WriteLine("Computer chose SCISSORS");
- if (inputPlayer == "ROCK")
- {
- Console.WriteLine("PLAYER WINS!!\n\n");
- scorePlayer++;
- }
- else if (inputPlayer == "PAPER")
- {
- Console.WriteLine("CPU WINS!!\n\n");
- scoreCpu++;
- }
- else if (inputPlayer == "SCISSORS")
- {
- Console.WriteLine("DRAW!!\n\n");
- }
- break;
- default:
- break;
- }
- }
- if (scorePlayer == 3)
- {
- Console.WriteLine("YOU WIN!!\n\n");
- }
- else if (scoreCpu == 3)
- {
- Console.WriteLine("YOU LOSE!!\n\n");
- }
- else
- {
- }
- Console.WriteLine("Do you want to play again?(y/n)");
- string loop = Console.ReadLine();
- if (loop == "y") playAgain = true;
- else if (loop == "n") playAgain = false;
- else { }
- Console.ReadKey();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement