Advertisement
Guest User

Ko_Papir_Ollo

a guest
Feb 17th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.77 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Saw
  8. {
  9.     class Program
  10.     {
  11.         static Random rnd = new Random();
  12.  
  13.         static void Main(string[] args)
  14.         {
  15.             string inputPlayer, inputCPU;
  16.             int randomInt;
  17.            
  18.             bool playAgain = true;
  19.  
  20.             while (playAgain)
  21.             {
  22.                 int scorePlayer = 0;
  23.                 int scoreCpu = 0;
  24.  
  25.  
  26.  
  27.                 while (scorePlayer < 3 && scoreCpu < 3)
  28.             {
  29.  
  30.            
  31.             Console.Write("Choose between ROCK, PAPER and SCISSORS:  ");
  32.  
  33.  
  34.             inputPlayer = Console.ReadLine().ToUpper();
  35.  
  36.             Random rnd = new Random();
  37.             randomInt = rnd.Next(1, 4);
  38.  
  39.             switch(randomInt)
  40.             {
  41.                 case 1:
  42.                     inputCPU = "ROCK";
  43.                     Console.WriteLine("Computer chose ROCK");
  44.  
  45.                     if (inputPlayer == "ROCK")
  46.                     {
  47.                         Console.WriteLine("DRAW!!\n\n");
  48.  
  49.                     }
  50.  
  51.                     else if (inputPlayer == "PAPER")
  52.                     {
  53.                         Console.WriteLine("PLAYER WINS!!\n\n");
  54.                         scorePlayer++;
  55.                     }
  56.  
  57.                     else if (inputPlayer == "SCISSORS")
  58.                     {
  59.                         Console.WriteLine("CPU WINS!!\n\n");
  60.                         scoreCpu++;
  61.                     }
  62.                     break;
  63.  
  64.                 case 2:
  65.                     inputCPU = "PAPER";
  66.                     Console.WriteLine("Computer chose PAPER");
  67.  
  68.                     if (inputPlayer == "ROCK")
  69.                     {
  70.                         Console.WriteLine("CPU WINS!!\n\n");
  71.                         scoreCpu++;
  72.  
  73.                     }
  74.  
  75.                     else if (inputPlayer == "PAPER")
  76.                     {
  77.                         Console.WriteLine("DRAW!!\n\n");
  78.                        
  79.                     }
  80.  
  81.                     else if (inputPlayer == "SCISSORS")
  82.                     {
  83.                         Console.WriteLine("PLAYER WINS!!\n\n");
  84.                         scorePlayer++;
  85.                     }
  86.                     break;
  87.                    
  88.  
  89.                 case 3:
  90.                     inputCPU = "SCISSORS";
  91.                     Console.WriteLine("Computer chose SCISSORS");
  92.  
  93.                     if (inputPlayer == "ROCK")
  94.                     {
  95.                         Console.WriteLine("PLAYER WINS!!\n\n");
  96.                         scorePlayer++;
  97.  
  98.                     }
  99.  
  100.                     else if (inputPlayer == "PAPER")
  101.                     {
  102.                         Console.WriteLine("CPU WINS!!\n\n");
  103.                         scoreCpu++;
  104.                     }
  105.  
  106.                     else if (inputPlayer == "SCISSORS")
  107.                     {
  108.                         Console.WriteLine("DRAW!!\n\n");
  109.                        
  110.                     }
  111.                     break;
  112.                 default:
  113.                     break;
  114.                 }
  115.  
  116.             }
  117.             if (scorePlayer == 3)
  118.             {
  119.                 Console.WriteLine("YOU WIN!!\n\n");
  120.             }
  121.             else if (scoreCpu == 3)
  122.             {
  123.                 Console.WriteLine("YOU LOSE!!\n\n");
  124.  
  125.             }
  126.             else
  127.             {
  128.  
  129.             }
  130.  
  131.             Console.WriteLine("Do you want to play again?(y/n)");
  132.  
  133.             string loop = Console.ReadLine();
  134.  
  135.                 if (loop == "y") playAgain = true;
  136.              
  137.                 else if (loop == "n") playAgain = false;
  138.  
  139.                 else { }
  140.  
  141.  
  142.  
  143.                 Console.ReadKey();
  144.  
  145.             }
  146.  
  147.         }
  148.     }
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement