static void Main(string[] args) { // Welcome Message Console.WriteLine("\nWelcome to The Game of Rock --- Paper --- Scissors\n"); Console.Write("Please Enter Your Name \n---> "); string Name = Validation.GetValidString(); Console.WriteLine(""); // Who Does The User Want To Play Against? Console.WriteLine("Would You Like to Play Against The Rock or The Random? Please Type the Word Rock or Random"); string Opponent = Validation.GetValidOpponent(); // Player's Choice Console.WriteLine(); Console.WriteLine($"You Chose {Opponent} -- Let's Begin!\n"); string ComputerChoice = ""; // Start Looping Here while (true) { // Create Instance of Human Player --- Get Human Version of GetRoshambo Method HumanPlayer h = new HumanPlayer(); string HumanChoice = h.GetRoshambo(); // Choose Opponent if (Opponent == "RANDOM") { // Create Instance of Random Player --- Get Random Version of GetRoshambo Method RandomPlayer rp = new RandomPlayer(); ComputerChoice = rp.GetRoshambo(); } else { // Create Instance of Rock Player --- Get Rock Version of GetRoshambo Method RockPlayer rock = new RockPlayer(); ComputerChoice = rock.GetRoshambo(); } GetOutput(HumanChoice, ComputerChoice, Name); // Game Output Console.WriteLine(); Console.WriteLine(Name + ": " + HumanChoice); Console.WriteLine(Opponent + ": " + ComputerChoice); // Call Continue Method if (!GetContinue()) { return; } } }
static void Main(string[] args) { do { string output1 = ""; string output2 = ""; string choice; HumanPlayer user = new HumanPlayer(); RockPlayer rck = new RockPlayer(); RandomPlayer rndm = new RandomPlayer(); Console.WriteLine("Welcome to Rock Paper Scissors!\n"); Console.WriteLine("Enter your name: "); string userName = Console.ReadLine(); Console.WriteLine("\nWho would you like to play? Rocky or Jokester?"); Console.WriteLine("Enter R or J: "); choice = ValidateConsoleInput.GetValidStringPlayerChoice(); if (choice == "r") { output1 = user.GetRoshambo(); //assigning a value from the human player method output2 = rck.GetRoshambo(); Console.WriteLine($"{userName}: {output1}"); Console.WriteLine($"Rocky: {output2}"); if (output1 == "Paper") { Console.WriteLine("You WIN! Hooray!"); } if (output1 == "Scissors") { Console.WriteLine("You LOSE! BA HA HA"); } if (output1 == "Rock") { Console.WriteLine("DRAW!"); } } if (choice == "j") { output1 = user.GetRoshambo(); output2 = rndm.GetRoshambo(); Console.WriteLine($"{userName}: {output1}"); Console.WriteLine($"Jokester: {output2}"); if (output1 == output2) { Console.WriteLine("DRAW!"); } else if (((output1 == "Paper") && (output2 == "Rock")) || ((output1 == "Rock") && (output2 == "Scissors") || ((output1 == "Scissors") && (output2 == "Paper")))) { Console.WriteLine("You WIN! Hooray!"); } else { Console.WriteLine("You LOSE! BA HA HA"); } } } while (ValidateConsoleInput.Continue()); //Console.WriteLine($"{userName}: {user.GetRoshambo()}"); //Console.WriteLine($"Rock player: {rck.GetRoshambo()}"); //Console.WriteLine($"Random player: {rndm.GetRoshambo()}"); }