Advertisement
Uriel133

First project - Rock, Paper, Scissors

Apr 14th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.24 KB | None | 0 0
  1. static void Main (string[] args)
  2. {
  3. int score = 0;
  4. int pcscore = 0;
  5. do {
  6. Console.WriteLine("Choose: Rock / Paper / Scissors");
  7. string choice = Console.ReadLine();
  8. string pcChoise;
  9. Random rnd = new Random();
  10. randomint = rnd.Next(1,3);
  11. switch (randomint)
  12. {
  13. case 1:
  14. pcChoise = "Rock";
  15. break;
  16. case 2:
  17. pcChoise = "Paper";
  18. break;
  19. case 3:
  20. pcChoise = "Scissors";
  21. break;
  22. }
  23. Console.WriteLine("Computer chose " + pcChoise);
  24. if (choice == pcChoise)
  25. {
  26. Console.WriteLine("Draw");
  27. }
  28. if (choice == "Rock")
  29. {
  30. if (pcChoise == "Paper")
  31. {
  32. Console.WriteLine("Computer won");
  33. pcscore++;
  34. }
  35. if (pcChoice == "Scissors")
  36. {
  37. Console WriteLine("You won");
  38. score++;
  39. }
  40. }
  41. if (choice == "Paper")
  42. {
  43. if (pcChoice == "Rock")
  44. {
  45. Console.WriteLine("You won");
  46. score++;
  47. }
  48. if (pcChoise == "Scissors")
  49. {
  50. Console.WriteLine("Computer won");
  51. pcscore++;
  52. }
  53. }
  54. if (choice == "Scissors")
  55. {
  56. if (pcChoice == "Rock")
  57. {
  58. Console.WriteLine("Computer won");
  59. pcscore++;
  60. }
  61. if (pcChoice == "Paper")
  62. {
  63. Console.WriteLine("You won");
  64. score++;
  65. }
  66. }
  67. }
  68. Console.WriteLine("Press 'y' to Continue / 'x' to stop");
  69. char cont = char.Parse(Console.ReadLine());
  70. }
  71. while (cont == y);
  72. Console.WriteLine("Your Score: {0}",score);
  73. Console.WriteLine("PC Score: {0}",pcscore);
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement