Advertisement
Guest User

RockPaperScissors

a guest
Feb 15th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.17 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace RockPaperScissors1
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             string imputPlayer;
  13.             string imputCPU;
  14.             int randomInt;
  15.             int scoreCPU = 0;
  16.             int scorePlyer = 0;
  17.             while (scoreCPU < 3 && scorePlyer < 3)
  18.             {
  19.  
  20.  
  21.                 Console.Write("Choose between Rock,Paper and Scissors:  ");
  22.                 imputPlayer = Console.ReadLine();
  23.                 Random rng = new Random();
  24.                 randomInt = rng.Next(1, 4);
  25.  
  26.                 switch (randomInt)
  27.                 {
  28.                     case 1:
  29.                         imputCPU = "Rock";
  30.                         Console.WriteLine("COMPUTER CHOSE ROCK");
  31.                         if (imputPlayer == "Rock")
  32.                         {
  33.                             Console.WriteLine("DRAW!");
  34.                         }
  35.                         else if (imputPlayer == "Paper")
  36.                         {
  37.                             Console.WriteLine("PLAYER WIN!");
  38.                             scorePlyer++;
  39.                         }
  40.                         else if (imputPlayer == "Scissors")
  41.                         {
  42.                             Console.WriteLine("COMPUTER WIN!");
  43.                             scoreCPU++;
  44.                         }
  45.                         break;
  46.                     case 2:
  47.                         imputCPU = "Paper";
  48.                         Console.WriteLine("COMPUTER CHOSE PAPER");
  49.                         if (imputPlayer == "Rock")
  50.                         {
  51.                             Console.WriteLine("COMPUTER WIN!");
  52.                             scoreCPU++;
  53.                         }
  54.                         else if (imputPlayer == "Paper")
  55.                         {
  56.                             Console.WriteLine("DRAW!");
  57.                         }
  58.                         else if (imputPlayer == "Scissors")
  59.                         {
  60.                             Console.WriteLine("PLAYER WIN!");
  61.                             scorePlyer++;
  62.                         }
  63.                         break;
  64.                     case 3:
  65.                         imputCPU = "Scissors";
  66.                         Console.WriteLine("COMPUTER CHOSE SCISSORS");
  67.                         if (imputPlayer == "Rock")
  68.                         {
  69.                             Console.WriteLine("PLAYER WIN!");
  70.                             scorePlyer++;
  71.                         }
  72.                         else if (imputPlayer == "Paper")
  73.                         {
  74.                             Console.WriteLine("COMPUTER WIN!");
  75.                             scoreCPU++;
  76.                         }
  77.                         else if (imputPlayer == "Scissors")
  78.                         {
  79.                             Console.WriteLine("DRAW!");
  80.                         }
  81.                         break;
  82.                    
  83.                 }
  84.                 Console.WriteLine("Player score :{0}",scorePlyer);
  85.                 Console.WriteLine("Computer score :{0}", scoreCPU);
  86.             }
  87.         }
  88.     }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement