MartinEesmaa

Validation Game

Feb 14th, 2022 (edited)
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.46 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace tester123
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             string input;
  13.             bool exit = false;
  14.             do
  15.             {
  16.                 do
  17.                 {
  18.                     Console.WriteLine("Please enter rock, paper or scissors");
  19.                     input = Console.ReadLine();
  20.                 }
  21.                 while (input != "Rock" && input != "Paper" && input != "Scissors");
  22.                 Console.WriteLine("Thank you for choosing {0}", input);
  23.                 Console.Beep();
  24.                 Console.ReadLine();
  25.                 Console.Clear();
  26.                 Console.Beep();
  27.                 Console.WriteLine("Do you wanna play against Computer or no means exit? Y/N?");
  28.  
  29.                 string input2 = Console.ReadLine();
  30.  
  31.                 if (input2 == "Y")
  32.                 {
  33.                     Random random = new Random();
  34.                     bool playAgain = true;
  35.                     String player;
  36.                     String computer;
  37.                     while (playAgain)
  38.                     {
  39.                         player = "";
  40.                         computer = "";
  41.                         while (player != "ROCK" && player != "PAPER" && player != "SCISSORS")
  42.                         {    
  43.                             Console.Write("Rock, Paper or Scissors?");
  44.                             player = Console.ReadLine();
  45.                             player = player.ToUpper();
  46.                         }
  47.                         Console.WriteLine();
  48.                         switch (random.Next(1, 4))
  49.                         {
  50.                             case 1:
  51.                                 computer = "Rock";
  52.                                 break;
  53.                             case 2:
  54.                                 computer = "Paper";
  55.                                 break;
  56.                             case 3:
  57.                                 computer = "Scissor";
  58.                                 break;
  59.                         }
  60.  
  61.                         Console.WriteLine("Player: " + player);
  62.                         Console.WriteLine("Computer: " + computer);
  63.                     }
  64.                 }
  65.                 else if (input2 == "N")
  66.                 {
  67.                     exit = true;
  68.                 }
  69.             } while (exit == false);
  70.         }
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment