Advertisement
Uriel133

Rock Paper Scissors C#

Apr 22nd, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | None | 0 0
  1. Start:
  2. string choice, pcChoice;
  3. int randomInt;
  4. Console.WriteLine("Rock / Paper / Scissors");
  5. choice = Console.ReadLine();
  6. random rnd = new random();
  7. randomInt = rnd.Next(1,4);
  8. switch (randomInt)
  9. {
  10. case 1:
  11. pcChoice = "rock";
  12. break;
  13. case 2:
  14. pcChoice = "paper";
  15. break;
  16. case 3:
  17. pcChoice = "scissors";
  18. break;
  19. default:
  20. Console.WriteLine("invalid input, try again");
  21. goto Start;
  22. break;
  23. }
  24. if (choice == pcChoise)
  25. {
  26. Console.WriteLine("Draw");
  27. }
  28. if (choice == "rock")
  29. {
  30. if (pcChoise == "paper")
  31. {
  32. Console.WriteLine("Computer win");
  33. }
  34. if (pcChoise == "scissors")
  35. {
  36. Console.WriteLine("You win");
  37. }
  38. }
  39. if (choise == "paper")
  40. {
  41. if (pcChoise == "rock")
  42. {
  43. Console.WriteLine("You win");
  44. }
  45. if (pcChoise == "scissors")
  46. {
  47. Console.WriteLine("Computer win");
  48. }
  49. }
  50. if (choice == "scissors")
  51. {
  52. if (pcChoice == "rock")
  53. {
  54. Console.WriteLine("Computer win");
  55. }
  56. if (pcChoice == "paper")
  57. {
  58. Console.WriteLine("You win");
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement