using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Activity_1_Rock_paper_scissors_Game { class Program { enum StateOfPlay { ROCK = 0, PAPER = 1, SCISSORS = 2 }; static Random randomChoice = new Random(100); static void Main(string[] args) { int wintimes = 0; while(true) { Console.WriteLine(" Let's play Rock Paper Scissors\n"); Console.WriteLine("Select your move:\n"); //StateOfPlay state = StateOfPlay.SCISSORS; string[] ChoiceOfPlat = { "Rock", "Paper", "Scissors" }; for (int i = 0; i < 3; i++) { if (i < 2) { Console.WriteLine(" For {0}\t enter {1}", ChoiceOfPlat[i], i); } else { Console.WriteLine(" For {0}\t enter {1}\n", ChoiceOfPlat[i], i); } } //int Choice = randomChoice.Next(1,3); int Choice = new Random(Guid.NewGuid().GetHashCode()).Next(0, 3); Console.Write("Enter your single letter <0, 1 or 2>: "); int Your_choice = int.Parse(Console.ReadLine()); Console.WriteLine("\n"); //StateOfPlay state = StateOfPlay.SCISSORS; switch (Your_choice) { case 0: if (Choice == 0) { Console.WriteLine(" I played ROCK and you have played ROCK\n"); Console.WriteLine(" Great minds think alike!\n"); break; } if (Choice == 1) { Console.WriteLine(" I played PAPER and you have played ROCK\n"); Console.WriteLine(" I win!\n"); break; } if (Choice == 2) { Console.WriteLine(" I played SCISSORS and you have played ROCK\n"); Console.WriteLine(" You won, lucky choice!\n"); wintimes++; } break; case 1: if (Choice == 0) { Console.WriteLine(" I played ROCK and you have played PAPER\n"); Console.WriteLine(" You won, lucky choice!\n"); wintimes++; break; } if (Choice == 1) { Console.WriteLine(" I played PAPER and you have played PAPER\n"); Console.WriteLine(" Great minds think alike!\n"); break; } if (Choice == 2) { Console.WriteLine(" I played SCISSORS and you have played PAPER\n"); Console.WriteLine(" I win!\n"); } break; case 2: if (Choice == 0) { Console.WriteLine(" I played ROCK and you have played SCISSORS\n"); Console.WriteLine(" I win!\n"); break; } if (Choice == 1) { Console.WriteLine(" I played PAPER and you have played SCISSORS\n"); Console.WriteLine(" You won, lucky choice!\n"); wintimes++; break; } if (Choice == 2) { Console.WriteLine(" I played SCISSORS and you have played SCISSORS\n"); Console.WriteLine(" Great minds think alike!\n"); } break; default: Console.WriteLine("You don't tell wude\n"); break; } string jxm; Console.WriteLine("Do you want to try again ? Please tell me NO to stop or else to continue"); jxm = Console.ReadLine(); if (jxm == "NO" || jxm == "no") { break; } Console.WriteLine("\n"); } Console.Write("Luck boy your wintimes:"); Console.WriteLine(wintimes); Console.WriteLine("Press and key tp exit ..."); Console.ReadKey(); } } }
建议你先使用代码格式化一下,这样看的好难
您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~
如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~
ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632