C# rock-paper-scissors game 🗿

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 พ.ย. 2024

ความคิดเห็น • 61

  • @BroCodez
    @BroCodez  3 ปีที่แล้ว +38

    using System;
    namespace MyFirstProgram
    {
    class Program
    {
    static void Main(string[] args)
    {
    Random random = new Random();
    bool playAgain = true;
    String player;
    String computer;
    String answer;
    while (playAgain)
    {
    player = "";
    computer = "";
    answer = "";
    while (player != "ROCK" && player != "PAPER" && player != "SCISSORS") {
    Console.Write("Enter ROCK, PAPER, or SCISSORS: ");
    player = Console.ReadLine();
    player = player.ToUpper();
    }

    switch (random.Next(1, 4))
    {
    case 1:
    computer = "ROCK";
    break;
    case 2:
    computer = "PAPER";
    break;
    case 3:
    computer = "SCISSORS";
    break;
    }
    Console.WriteLine("Player: " + player);
    Console.WriteLine("Computer: " + computer);
    switch (player)
    {
    case "ROCK":
    if (computer == "ROCK")
    {
    Console.WriteLine("It's a draw!");
    }
    else if (computer == "PAPER")
    {
    Console.WriteLine("You lose!");
    }
    else
    {
    Console.WriteLine("You win!");
    }
    break;
    case "PAPER":
    if (computer == "ROCK")
    {
    Console.WriteLine("You win!");
    }
    else if (computer == "PAPER")
    {
    Console.WriteLine("It's a draw!");
    }
    else
    {
    Console.WriteLine("You lose!");
    }
    break;
    case "SCISSORS":
    if (computer == "ROCK")
    {
    Console.WriteLine("You lose!");
    }
    else if (computer == "PAPER")
    {
    Console.WriteLine("You win!");
    }
    else
    {
    Console.WriteLine("It's a draw!");
    }
    break;
    }
    Console.Write("Would you like to play again (Y/N): ");
    answer = Console.ReadLine();
    answer = answer.ToUpper();
    if (answer == "Y")
    {
    playAgain = true;
    }
    else
    {
    playAgain = false;
    }

    }
    Console.WriteLine("Thanks for playing!");
    Console.ReadKey();
    }
    }
    }

    • @dapianoman20
      @dapianoman20 2 ปีที่แล้ว +1

      I decided to create a "best of 3" scenario (which is often what happens in real life) and before I'd watched the video had finally come up with the following code:
      Random random = new Random();
      String again = "y";
      int computer_rand;
      int computer_wins;
      int player_wins;
      while (again == "y")
      {
      Console.WriteLine("Welcome to Rock, Paper, Scissors!");
      Console.WriteLine("Best of 3 rounds wins!");
      Console.ReadLine();
      computer_wins = 0;
      player_wins = 0;
      while (player_wins < 2 && computer_wins < 2)
      {
      String player = "";
      String computer = "";
      while (player != "rock" && player != "paper" && player != "scissors")
      {
      Console.WriteLine("Choose rock, paper or scissors: ");
      player = Console.ReadLine();
      player = player.ToLower();
      }
      computer_rand = random.Next(1, 4);
      switch (computer_rand)
      {
      case 1:
      computer = "rock";
      break;
      case 2:
      computer = "paper";
      break;
      default:
      computer = "scissors";
      break;
      }
      Console.WriteLine("Computer is " + computer);
      if (computer == player)
      {
      Console.WriteLine("TIE - REMATCH");
      Console.ReadLine();
      }
      else if (computer == "rock")
      {
      switch (player)
      {
      case "paper":
      Console.WriteLine("You win the round");
      player_wins += 1;
      Console.WriteLine("You: " + player_wins + " Computer: " + computer_wins);
      Console.ReadLine();
      break;
      case "scissors":
      Console.WriteLine("Computer wins the round");
      computer_wins += 1;
      Console.WriteLine("You: " + player_wins + " Computer: " + computer_wins);
      Console.ReadLine();
      break;
      }
      }
      else if (computer == "paper")
      {
      switch (player)
      {
      case "scissors":
      Console.WriteLine("You win the round");
      player_wins += 1;
      Console.WriteLine("You: " + player_wins + " Computer: " + computer_wins);
      Console.ReadLine();
      break;
      case "rock":
      Console.WriteLine("Computer wins the round");
      computer_wins += 1;
      Console.WriteLine("You: " + player_wins + " Computer: " + computer_wins);
      Console.ReadLine();
      break;
      }
      }
      else if (computer == "scissors")
      {
      switch (player)
      {
      case "rock":
      Console.WriteLine("You win the round");
      player_wins += 1;
      Console.WriteLine("You: " + player_wins + " Computer: " + computer_wins);
      Console.ReadLine();
      break;
      case "paper":
      Console.WriteLine("Computer wins the round");
      computer_wins += 1;
      Console.WriteLine("You: " + player_wins + " Computer: " + computer_wins);
      Console.ReadLine();
      break;
      }
      }
      }
      Console.WriteLine("Your wins: " + player_wins);
      Console.WriteLine("Computer wins: " + computer_wins);
      if (computer_wins > player_wins)
      {
      Console.WriteLine("Sorry, you lose. Computer wins the best of three");
      }
      else
      {
      Console.WriteLine("Congratulations! You won the best of three!");
      }
      Console.ReadLine();
      Console.WriteLine("Play again? y/n?");
      again = Console.ReadLine();
      }
      Console.WriteLine("Thanks for playing!");
      Console.ReadKey();

    • @ChandranshuKumar
      @ChandranshuKumar ปีที่แล้ว

      A shorter version of this code -
      namespace ConsoleTesting
      {
      internal class Program
      {
      static void Main(string[] args)
      {
      var random = new Random();
      var playAgain = true;
      while (playAgain)
      {
      Console.Write("Enter ROCK, PAPER, or SCISSORS: ");
      var player = Console.ReadLine().ToUpper();
      while (player != "ROCK" && player != "PAPER" && player != "SCISSORS")
      {
      Console.Write("Invalid input, enter ROCK, PAPER, or SCISSORS: ");
      player = Console.ReadLine().ToUpper();
      }
      var computer = random.Next(1, 4) switch
      {
      1 => "ROCK",
      2 => "PAPER",
      _ => "SCISSORS"
      };
      Console.WriteLine("Player: " + player);
      Console.WriteLine("Computer: " + computer);
      var result = player switch
      {
      "ROCK" when computer == "ROCK" => "It's a draw!",
      "ROCK" when computer == "PAPER" => "You lose!",
      "ROCK" => "You win!",
      "PAPER" when computer == "ROCK" => "You win!",
      "PAPER" when computer == "PAPER" => "It's a draw!",
      "PAPER" => "You lose!",
      "SCISSORS" when computer == "ROCK" => "You lose!",
      "SCISSORS" when computer == "PAPER" => "You win!",
      _ => "It's a draw!"
      };
      Console.WriteLine(result);
      Console.Write("Would you like to play again (Y/N): ");
      playAgain = Console.ReadLine().ToUpper() == "Y";
      }
      Console.WriteLine("Thanks for playing!");
      Console.ReadKey();
      }
      }
      }

    • @ChandranshuKumar
      @ChandranshuKumar ปีที่แล้ว

      Thanks bro ☺

    • @pruthvioruganti3984
      @pruthvioruganti3984 ปีที่แล้ว

      @@ChandranshuKumar its not good

    • @ВладМаринов-г8и
      @ВладМаринов-г8и ปีที่แล้ว

      is my code ok?
      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Security.Cryptography;
      using System.Text;
      using System.Threading.Tasks;
      namespace rock_paper_scissors_game
      {
      internal class Program
      {
      static void Main(string[] args)
      {
      Random random = new Random();
      String game = "ROCK, PAPER, SCISSORS: ";
      Console.Write(game);
      String user_input = Console.ReadLine().ToLower();
      int random_char = random.Next(0, 3);
      while (true)
      {
      while (user_input != "paper" || user_input != "rock" || user_input != "scissors")
      {
      Console.WriteLine("please, write either paper or rock or scissors");

      Console.Write("ROCK, PAPER, SCISSORS: ");
      user_input = Console.ReadLine();
      random_char = random.Next(0, 3);
      if (user_input == "paper" || user_input == "rock" || user_input == "scissors")
      {
      break;
      }
      }
      if (random_char == 0 && user_input == "paper" || random_char == 1 && user_input == "rock" || random_char == 2 && user_input == "scissors")
      {
      if (random_char == 0)
      {
      Console.WriteLine("paper");
      }

      else if (random_char == 1)
      {
      Console.WriteLine("rock");
      }
      else if (random_char == 0)
      {
      Console.WriteLine("scissors");
      }
      Console.WriteLine("draw!");
      }
      else if (random_char == 0 && user_input == "rock" || random_char == 1 && user_input == "scissors" || random_char == 2 && user_input == "paper")
      {
      if (random_char == 0)
      {
      Console.WriteLine("paper");
      }
      else if (random_char == 1)
      {
      Console.WriteLine("rock");
      }
      else if (random_char == 0)
      {
      Console.WriteLine("scissors");
      }
      Console.WriteLine("VICTORYYY");
      }
      else if (random_char == 0 && user_input == "scissors" || random_char == 1 && user_input == "paper" || random_char == 2 && user_input == "rock")
      {
      if (random_char == 0)
      {
      Console.WriteLine("paper");
      }
      else if (random_char == 1)
      {
      Console.WriteLine("rock");
      }
      else if (random_char == 0)
      {
      Console.WriteLine("scissors");
      }
      Console.WriteLine("you lost :(");
      }
      Console.WriteLine("do you wanna continue?(y/n): ");
      String continue_or_quit = Console.ReadLine();
      if (continue_or_quit == "y")
      {
      Console.Write("ROCK, PAPER, SCISSORS: ");
      user_input = Console.ReadLine();
      random_char = random.Next(0, 3);
      }
      else if (continue_or_quit == "n")
      {
      Console.WriteLine("press any key to quit");
      break;
      }
      }
      }
      }
      }

  • @Dawbry
    @Dawbry 2 ปีที่แล้ว +4

    Thank you! Great logic, and explanation!

  • @alexandregb566
    @alexandregb566 ปีที่แล้ว +5

    I think your computer was tricking you in this game. I've been following your playlist for weeks, and I've been learning a lot with you. Thanks for making this video.

  • @manuelhernandez2017
    @manuelhernandez2017 ปีที่แล้ว +1

    Bro, fantastic explanation of logic and clean coding and practice

  • @qarnma0h1
    @qarnma0h1 6 หลายเดือนก่อน

    Thank you so much. Very well explained.

  • @dijol739
    @dijol739 3 ปีที่แล้ว +1

    Dude, Big thanks for explaining it! Now I understand it better.

  • @ragnal82
    @ragnal82 ปีที่แล้ว

    Amazing explanation BRO. Thx again for your input.

  • @Aahegaaooo
    @Aahegaaooo ปีที่แล้ว

    Thank you so much! Finally some good explanation, comparing to my teachers)

  • @guillermodanielmazzarigiov1768
    @guillermodanielmazzarigiov1768 2 ปีที่แล้ว

    Nice one bro!!! Thanks for sharing, learned a lot with this video!!

  • @BereketEndale-g1e
    @BereketEndale-g1e ปีที่แล้ว

    It's amazing bro 👌👌👌

  • @zntei2374
    @zntei2374 3 ปีที่แล้ว +15

    Random comment = new Random();

    • @anbu3435
      @anbu3435 ปีที่แล้ว +2

      That's kinda random

  • @clark435
    @clark435 2 ปีที่แล้ว +3

    shortcut for random number:
    int computer = new Random().Next(1,4);

  • @schleppvideos
    @schleppvideos 5 หลายเดือนก่อน +2

    all that code for such a simple little program.
    what the hell did i get myself in to...

    • @IsRaphaelGo
      @IsRaphaelGo 2 หลายเดือนก่อน

      It's simple to understand so it's balanced I'd say

  • @The_Ancient_Guardian
    @The_Ancient_Guardian ปีที่แล้ว

    thanks for playing.

  • @definitelynotchris4776
    @definitelynotchris4776 หลายเดือนก่อน

    bro brought a gun to a rock paper scissors game

  • @spartanranger
    @spartanranger 3 ปีที่แล้ว

    Thanks for the video Brother

  • @user-gk9fn8pu1f
    @user-gk9fn8pu1f ปีที่แล้ว

    tnks

  • @Ael.Gwynnio
    @Ael.Gwynnio 3 ปีที่แล้ว

    Thanks man !

  • @andreeduardo8392
    @andreeduardo8392 3 ปีที่แล้ว

    Thank you man!!

  • @ahmedahmed-x8j
    @ahmedahmed-x8j 3 หลายเดือนก่อน

    Rock!!

  • @alexanderjwilson7420
    @alexanderjwilson7420 2 ปีที่แล้ว

    THANKS BRO!

  • @benedictcherlet8583
    @benedictcherlet8583 ปีที่แล้ว

    Thanks bro

  •  3 ปีที่แล้ว

    Thanks!

  • @dennisflorita4941
    @dennisflorita4941 2 ปีที่แล้ว +1

    This is using the console application?

  • @oheil5694
    @oheil5694 2 ปีที่แล้ว

    Thanks u r doing well

  • @HamidKhan-b6x
    @HamidKhan-b6x 8 หลายเดือนก่อน

    😊thnx

  • @renasshawkat7730
    @renasshawkat7730 9 หลายเดือนก่อน +1

    if (player == "rock" && cpu == "rock" || player == "paper" && cpu == "paper" || player == "scissors" && cpu == "scissors")
    {
    Console.WriteLine("Draw");
    }
    else if (player == "rock" && cpu == "scissors" || player == "scissors" && cpu == "paper" || player == "paper" && cpu == "rock")
    {
    Console.WriteLine("You Won!");
    }
    else
    {
    Console.WriteLine("Cpu won");
    }

  • @genevievebennett8983
    @genevievebennett8983 3 ปีที่แล้ว +1

    noice

  • @shoxruxqodiraliyev531
    @shoxruxqodiraliyev531 2 ปีที่แล้ว

    thank you

  • @phos2994
    @phos2994 10 หลายเดือนก่อน

    I took the final result and added a score system of first to 3. Whichever wins (player or computer) it displays they won and the score after each win.
    using System;
    namespace MyFirstProgram
    {
    class Program
    {
    static void Main(string[] args)
    {
    Random random = new Random();
    bool playAgain = true;
    String player;
    String computer;
    String answer;
    int playerWins = 0;
    int computerWins = 0;
    while (playAgain)
    {
    player = "";
    computer = "";
    answer = "";

    while (player != "ROCK" && player != "PAPER" && player != "SCISSORS")
    {
    Console.WriteLine("Enter ROCK, PAPER, or SCISSORS: ");
    player = Console.ReadLine();
    player = player.ToUpper();
    }
    switch (random.Next(1, 4))
    {
    case 1:
    computer = "ROCK";
    break;
    case 2:
    computer = "PAPER";
    break;
    case 3:
    computer = "SCISSORS";
    break;
    }
    Console.WriteLine("Player: " + player);
    Console.WriteLine("Computer: " + computer);
    switch (player)
    {
    case "ROCK":
    if (computer == "ROCK")
    {
    Console.WriteLine("It's a draw!");
    }
    else if (computer == "PAPER")
    {
    Console.WriteLine("You lose!");
    computerWins++;
    }
    else
    {
    Console.WriteLine("You win!");
    playerWins++;
    }
    break;
    case "PAPER":
    if (computer == "ROCK")
    {
    Console.WriteLine("You win!");
    playerWins++;
    }
    else if (computer == "PAPER")
    {
    Console.WriteLine("It's a draw!");
    }
    else
    {
    Console.WriteLine("You lose!");
    computerWins++;
    }
    break;
    case "SCISSORS":
    if (computer == "ROCK")
    {
    Console.WriteLine("You lose");
    computerWins++;
    }
    else if (computer == "PAPER")
    {
    Console.WriteLine("You win!");
    playerWins++;
    }
    else
    {
    Console.WriteLine("It's a draw!");
    }
    break;
    }
    Console.WriteLine("Current score: " + playerWins + " - " + computerWins);
    if (playerWins == 3)
    {
    Console.WriteLine("Congratulations, you win the series!");
    }
    else if (computerWins == 3)
    {
    Console.WriteLine("Damn bruh you suck lmaooo");
    }
    if (playerWins == 3 || computerWins == 3)
    {
    playerWins = 0;
    computerWins = 0;
    }
    Console.Write("Would you like to play again? (Y/N): ");
    answer = Console.ReadLine();
    answer = answer.ToUpper();
    if (answer == "Y")
    {
    playAgain = true;
    }
    else
    {
    playAgain = false;
    }
    }
    Console.WriteLine("Thanks for playing!");
    Console.ReadKey();
    }
    }
    }

  • @Infinity540
    @Infinity540 2 ปีที่แล้ว

    legend

  • @manuelhernandez2017
    @manuelhernandez2017 ปีที่แล้ว

    Accumulation of score/wins throughout several runs? Suggestions?

    • @CorneliusCorndogJr
      @CorneliusCorndogJr ปีที่แล้ว

      add some variables that go up for both the computer and player and add them into the if else statements ex:
      if(computer == player){
      System.Console.WriteLine("DRAW");
      playerScore++;
      computerScore++;
      }

  • @tailerderdon1371
    @tailerderdon1371 2 ปีที่แล้ว

    Hi! I'm a beginer, why you use String? I'm use string and the program worcs.

  • @CoolModderJaydonX
    @CoolModderJaydonX ปีที่แล้ว

    I actually made a basic UWP version so you can run it on Xbox, too.

  • @themasterofdeadoralive
    @themasterofdeadoralive 2 ปีที่แล้ว

    How do I put it to three rounds instead of 1 round, please help ASAP.

    • @dapianoman20
      @dapianoman20 2 ปีที่แล้ว

      I created it as a "Best of 3 rounds" using the following code:
      Random random = new Random();
      String again = "y";
      int computer_rand;
      int computer_wins;
      int player_wins;
      while (again == "y")
      {
      Console.WriteLine("Welcome to Rock, Paper, Scissors!");
      Console.WriteLine("Best of 3 rounds wins!");
      Console.ReadLine();
      computer_wins = 0;
      player_wins = 0;
      while (player_wins < 2 && computer_wins < 2)
      {
      String player = "";
      String computer = "";
      while (player != "rock" && player != "paper" && player != "scissors")
      {
      Console.WriteLine("Choose rock, paper or scissors: ");
      player = Console.ReadLine();
      player = player.ToLower();
      }
      computer_rand = random.Next(1, 4);
      switch (computer_rand)
      {
      case 1:
      computer = "rock";
      break;
      case 2:
      computer = "paper";
      break;
      default:
      computer = "scissors";
      break;
      }
      Console.WriteLine("Computer is " + computer);
      if (computer == player)
      {
      Console.WriteLine("TIE - REMATCH");
      Console.ReadLine();
      }
      else if (computer == "rock")
      {
      switch (player)
      {
      case "paper":
      Console.WriteLine("You win the round");
      player_wins += 1;
      Console.WriteLine("You: " + player_wins + " Computer: " + computer_wins);
      Console.ReadLine();
      break;
      case "scissors":
      Console.WriteLine("Computer wins the round");
      computer_wins += 1;
      Console.WriteLine("You: " + player_wins + " Computer: " + computer_wins);
      Console.ReadLine();
      break;
      }
      }
      else if (computer == "paper")
      {
      switch (player)
      {
      case "scissors":
      Console.WriteLine("You win the round");
      player_wins += 1;
      Console.WriteLine("You: " + player_wins + " Computer: " + computer_wins);
      Console.ReadLine();
      break;
      case "rock":
      Console.WriteLine("Computer wins the round");
      computer_wins += 1;
      Console.WriteLine("You: " + player_wins + " Computer: " + computer_wins);
      Console.ReadLine();
      break;
      }
      }
      else if (computer == "scissors")
      {
      switch (player)
      {
      case "rock":
      Console.WriteLine("You win the round");
      player_wins += 1;
      Console.WriteLine("You: " + player_wins + " Computer: " + computer_wins);
      Console.ReadLine();
      break;
      case "paper":
      Console.WriteLine("Computer wins the round");
      computer_wins += 1;
      Console.WriteLine("You: " + player_wins + " Computer: " + computer_wins);
      Console.ReadLine();
      break;
      }
      }
      }
      Console.WriteLine("Your wins: " + player_wins);
      Console.WriteLine("Computer wins: " + computer_wins);
      if (computer_wins > player_wins)
      {
      Console.WriteLine("Sorry, you lose. Computer wins the best of three");
      }
      else
      {
      Console.WriteLine("Congratulations! You won the best of three!");
      }
      Console.ReadLine();
      Console.WriteLine("Play again? y/n?");
      again = Console.ReadLine();
      }
      Console.WriteLine("Thanks for playing!");
      Console.ReadKey();

  • @marnus1154
    @marnus1154 ปีที่แล้ว

    Create video... If you guys want to test your skills a bit, try making it a best out of 3 game.. It's really not that hard and fun when you get it right (For reference i'm a newbie coder, so if I can do it so can you).

  • @AntwiGodwill-o8y
    @AntwiGodwill-o8y 6 หลายเดือนก่อน

    this is mine using System;
    public class HelloWorld
    {
    public static void Main(string[] args)
    {
    Console.WriteLine("Rock paper scissors");
    Random random = new Random();
    string playagain = "";
    while (playagain == "")
    {
    Console.Write("choose rock paper or scissors ");
    string answer = Console.ReadLine();
    answer = answer.ToUpper();
    while (answer != "ROCK" && answer != "PAPER" && answer != "SCISSORS" )
    {
    Console.Write("invalid choice choose ROCK PAPER or scissors ");
    answer = Console.ReadLine();
    }
    Console.WriteLine("You chose: "+answer);
    int computer = random.Next(1,4);
    string ai = "";
    switch (computer)
    {
    case 1:
    ai = "ROCK";
    break;
    case 2:
    ai = "PAPER";
    break;
    case 3:
    ai = "SCISSORS";
    break;
    }
    Console.WriteLine("Computer chose: "+ai);
    if (answer == "ROCK" && ai == "SCISSORS")
    {
    Console.WriteLine("you win");
    }
    else if (answer == "PAPER" && ai == "ROCK")
    {
    Console.WriteLine("you win");
    }
    else if (answer == "SCISSORS" && ai == "PAPER")
    {
    Console.WriteLine("you win");
    }
    else if (answer == "ROCK" && ai == "PAPER")
    {
    Console.WriteLine("you loose");
    }
    else if (answer == "PAPER" && ai == "SCISSORS")
    {
    Console.WriteLine("you loose");
    }
    else if (answer == "SCISSORS" && ai == "ROCK")
    {
    Console.WriteLine("you loose");
    }
    else if (answer == "ROCK" && ai == "ROCK")
    {
    Console.WriteLine("it is a tie");
    }
    else if (answer == "PAPER" && ai == "PAPER")
    {
    Console.WriteLine("it is a tie");
    }
    else if (answer == "SCISSORS" && ai == "SCISSORS")
    {
    Console.WriteLine("it is a tie");
    }
    else
    {
    Console.WriteLine("you loose");
    }
    Console.Write("press enter to play again type no to stop");
    playagain = Console.ReadLine();
    Console.WriteLine("");
    Console.WriteLine("");
    Console.WriteLine("");
    Console.WriteLine("");
    }
    Console.WriteLine("Thanks for playing this game");
    }
    }

  • @sandarubandara4437
    @sandarubandara4437 10 หลายเดือนก่อน

    string ifYouCantWin = "It's a dumb game" ;

  • @simik4830
    @simik4830 หลายเดือนก่อน

    for the aglorithm!

  • @DiegoValenciabajista
    @DiegoValenciabajista 2 ปีที่แล้ว

    when I try to use the "while" loop for stopping the user to input another thing that is not "ROCK" , "Paper" , "Scissors" , it tells me that I cannot use the "&&" for string variables... help?

    • @bledi7816
      @bledi7816 ปีที่แล้ว +1

      while (player != "ROCK" && player != "PAPER" && player != "SCISSORS")

  • @whitedinamo
    @whitedinamo 2 ปีที่แล้ว

    lesson check😇

  • @joshuasears3319
    @joshuasears3319 9 หลายเดือนก่อน

    random comment

  • @memy4460
    @memy4460 2 ปีที่แล้ว

    comment

  • @merdacast908
    @merdacast908 ปีที่แล้ว

    hey Bro,, is this considered a bad code? xD
    Thats how I've done before seeing your example:
    using System;
    using System.ComponentModel.Design;
    using System.Linq;
    using System.Threading.Channels;
    namespace projeto1
    {
    internal class Program
    {
    static void Main(string[] args)
    {

    bool PlayAgain = true;
    string cpuresponse = "";
    while (PlayAgain == true)
    {
    Random cpunumber = new Random();
    int cpunumber1 = cpunumber.Next(1, 3);

    //#1= tesoura, #2= papel, #3
    if (cpunumber1 == 1)
    { cpuresponse = "Tesoura"; }
    else if (cpunumber1 == 2)
    { cpuresponse = "Papel"; }
    else if (cpunumber1 == 3)
    { cpuresponse = "Pedra"; }
    Console.WriteLine("3...2...1... Pedra, papel ou tesooooura!?");
    string response = Console.ReadLine();
    Console.WriteLine(response + " VS " + cpuresponse);
    while (cpuresponse != response)
    {
    if (response == "Pedra" & cpuresponse == "Tesoura")
    {
    Console.WriteLine("Você venceu!");
    break;
    }
    else if (response == "Pedra" && cpuresponse == "Papel")
    {
    Console.WriteLine("Você perdeu!");
    break;
    }
    else if (response == "Tesoura" && cpuresponse == "Papel")
    {
    Console.WriteLine("Você ganhou!");
    break;
    }
    else if (response == "Tesoura" && cpuresponse == "Papel")
    {
    Console.WriteLine("Você ganhou!");
    break;
    }
    else if (response == "Tesoura" && cpuresponse == "Pedra")
    {
    Console.WriteLine("Você Perdeu!");
    break;
    }
    else if (response == "Papel" && cpuresponse == "Pedra")
    {
    Console.WriteLine("Você ganhou!");
    break;
    }
    else if(response == "Papel" && cpuresponse== "Tesoura")
    {
    Console.WriteLine("Você Perdeu!");
    break;
    }
    }
    if (response == cpuresponse)
    {
    Console.WriteLine(cpuresponse + " é igual a " + response + ". Empate, tenta de novo...");
    }
    Console.WriteLine("Quer jogar de novo? Y/N");
    string PlayAgainresponse = Console.ReadLine();
    if (PlayAgainresponse == "Y")
    {
    PlayAgain = true;
    }
    else { PlayAgain = false; }
    }
    Console.WriteLine("Obrigado por jogar!");
    }
    }
    }

  • @surroundedbygamers9061
    @surroundedbygamers9061 2 ปีที่แล้ว

    bool playAgain = true;
    Random random = new Random();
    while (playAgain)
    {
    int computerChoiceIdx = random.Next(1, 4);
    String computerChoice = "";
    if (computerChoiceIdx == 1)
    {
    computerChoice = "ROCK";
    }
    else if (computerChoiceIdx == 2)
    {
    computerChoice = "PAPER";
    }
    else
    {
    computerChoice = "SCISSORS";
    }
    Console.WriteLine(computerChoice);
    Console.Write("What Is Your Choice? (Rock, Paper Or Scissors) - ");
    String playerChoice = Console.ReadLine().ToUpper();
    if (computerChoice == playerChoice)
    {
    Console.WriteLine("It Is A Tie!!");
    }
    else if (playerChoice == "ROCK")
    {
    if (computerChoice == "PAPER")
    {
    Console.WriteLine("You Lose!.");
    }
    else if (computerChoice == "SCISSORS")
    {
    Console.WriteLine("You Win!!");
    }
    }
    else if (playerChoice == "PAPER")
    {
    if (computerChoice == "SCISSORS")
    {
    Console.WriteLine("You Lose!.");
    }
    else if (computerChoice == "ROCK")
    {
    Console.WriteLine("You Win!!");
    }
    }
    else if (playerChoice == "SCISSORS")
    {
    if (computerChoice == "ROCK")
    {
    Console.WriteLine("You Lose!.");
    }
    else if (computerChoice == "PAPER")
    {
    Console.WriteLine("You Win!!");
    }
    }
    Console.Write("Wanna Play Again? (Y/N) - ");
    String wannaPlayAgain = Console.ReadLine().ToUpper();
    if (wannaPlayAgain == "N")
    {
    playAgain = false;
    Console.Clear();
    Console.WriteLine("Byeeee!!!");
    }
    else
    {
    Console.Clear();
    }
    }

  • @teluguassaulter1703
    @teluguassaulter1703 ปีที่แล้ว +1

    Console.WriteLine("Bro code zindabad" + "fan from 🇮🇳 ")