static void Main(string[] args) { //UserPlayer player = new UserPlayer(""); RoshamboApp ra = new RoshamboApp(); ra.Welcome(); while (true) { RockyPlayer r = new RockyPlayer("Rocky"); Random rando = new Random(); RandyPlayer Randy = new RandyPlayer("Randy", rando); ra.Run(); Console.WriteLine("Play again? (y/n)"); string input = Console.ReadLine(); Console.Clear(); if (input.ToLower() == "y") { } else { break; } } Console.WriteLine("Thanks for playing!"); // Console.WriteLine($"{r.Name} throws{r.GeneratedRoshambo()}"); //for (int i =0; i< 1; i++) // { //Console.WriteLine($"{Randy.Name} throws {Randy.GeneratedRoshambo()}"); // } }
public void Run() { //User player should go here eventually UserPlayer user = new UserPlayer(""); RockyPlayer rocky = new RockyPlayer("Rocky"); Player Player = new RockyPlayer("error"); RandyPlayer randy = new RandyPlayer("Randy", rando); bool run = true; while (run) { try { Console.WriteLine("Would you like to play against Rocky or Randy?"); string answer = Console.ReadLine(); Console.Clear(); if (answer.ToLower() == "rocky") { Player = new RockyPlayer("Rocky"); break; } else if (answer.ToLower() == "randy") { Player = new RandyPlayer("Randy", rando); break; } else { Console.WriteLine("Sorry, I did not understand that input. Please try again!."); } } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(e.GetType()); } } string userRPS = user.GeneratedRoshambo().ToLower(); string opponentRPS = Player.GeneratedRoshambo().ToLower(); Console.WriteLine($"{name} you just threw: {userRPS}. "); Console.WriteLine($"Player {Player.Name} threw : {opponentRPS}. "); Console.WriteLine(""); if (userRPS == opponentRPS) { Console.WriteLine("Draw!"); } else if (userRPS == RPS.Rock) { if (opponentRPS == RPS.Paper) { Console.WriteLine("Opponent Wins!"); } else if (opponentRPS == RPS.Scissors) { Console.WriteLine("You Win!"); } } else if (userRPS == RPS.Scissors) { if (opponentRPS == RPS.Paper) { Console.WriteLine("You Win!"); } else if (opponentRPS == RPS.Rock) { Console.WriteLine("Opponent wins!"); } } else if (userRPS == RPS.Paper) { if (opponentRPS == RPS.Rock) { Console.WriteLine("You Win!"); } else if (opponentRPS == RPS.Scissors) { Console.WriteLine("Opponent wins!"); } } }