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()}"); }
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) { int playcount = 0; int wincount = 0; int Papcount = 0; int Rockcount = 0; int Scissorcount = 0; do { Console.WriteLine("which player do you want face?"); Console.WriteLine("1) Human "); Console.WriteLine("2) Stupid Computer "); Console.WriteLine("3) Random Computer "); Console.WriteLine("4) Hal (Smart Computer) "); int UserPick = Validate.RangeValidator(1, 4); Console.WriteLine("ok now choose: type 'rock', 'paper' or 'scissor'"); string UserPlay = Validate.GetValidString(); Console.WriteLine("================================="); //playcount Hal needs this switch (UserPick) { case 1: Human bob = new Human(); Console.WriteLine("Player 2 choose 'rock','paper' or 'scissors' dont look at above this line"); string Oplay = bob.GetRoshambo(); if (Oplay == UserPlay) { Console.WriteLine("draw"); } else if (Oplay == "scissors" && UserPlay == "rock") { Rockcount++; Console.WriteLine("player 1 wins"); } else if (Oplay == "scissors" && UserPlay == "paper") { Papcount++; Console.WriteLine("player 2 wins"); } else if (Oplay == "paper" && UserPlay == "scissors") { Scissorcount++; Console.WriteLine("Player 1 wins"); } else if (Oplay == "paper" && UserPlay == "rock") { Rockcount++; Console.WriteLine("player 2 wins"); } else if (Oplay == "rock" && UserPlay == "scissors") { Scissorcount++; Console.WriteLine("player 2 wns"); } else if (Oplay == "rock" && UserPlay == "paper") { Papcount++; Console.WriteLine("player 1 wins"); } break; case 2: RockPlayer DumbComp = new RockPlayer(); Console.WriteLine(DumbComp.GetRoshambo()); if (UserPlay == "rock") { Console.WriteLine("draw"); } else if (UserPlay == "scissors") { Console.WriteLine("you lose"); } else { Console.WriteLine("you win"); } break; case 3: RandomPlayer RanComp = new RandomPlayer(); string RanPlay = RanComp.GetRoshambo(); Console.WriteLine(RanPlay); if (RanPlay == UserPlay) { Console.WriteLine("draw"); } else if (RanPlay == "scissors" && UserPlay == "rock") { Console.WriteLine("you win"); } else if (RanPlay == "scissors" && UserPlay == "paper") { Console.WriteLine("computer 2 wins"); } else if (RanPlay == "paper" && UserPlay == "scissors") { Console.WriteLine("you win"); } else if (RanPlay == "paper" && UserPlay == "rock") { Console.WriteLine("computer 2 wins"); } else if (RanPlay == "rock" && UserPlay == "scissors") { Console.WriteLine("computer 2 wns"); } else if (RanPlay == "rock" && UserPlay == "paper") { Console.WriteLine("you win"); } break; case 4: //Track userplays if (UserPlay == "rock") { Rockcount++; } else if (UserPlay == "paper") { Papcount++; } else { Scissorcount++; } playcount++; string HalsPlay = Hal.GetRoshambo(playcount, wincount, Rockcount, Papcount, Scissorcount); if (HalsPlay == UserPlay) { Console.WriteLine("draw"); } else if (HalsPlay == "scissors" && UserPlay == "rock") { wincount++; Console.WriteLine("you win"); } else if (HalsPlay == "scissors" && UserPlay == "paper") { Console.WriteLine("Hal wins"); } else if (HalsPlay == "paper" && UserPlay == "scissors") { wincount++; Console.WriteLine("you win"); } else if (HalsPlay == "paper" && UserPlay == "rock") { Console.WriteLine("Hal wins"); } else if (HalsPlay == "rock" && UserPlay == "scissors") { Console.WriteLine("Hal wins"); } else if (HalsPlay == "rock" && UserPlay == "paper") { wincount++; Console.WriteLine("you win"); } break; } Console.WriteLine("==============================="); Console.WriteLine("win count: " + wincount); Console.WriteLine("playcount: " + playcount); Console.WriteLine("Rockcount: " + Rockcount); Console.WriteLine("Papercount: " + Papcount); Console.WriteLine("Scissor: " + Scissorcount); } while (Validate.Continue()); Console.WriteLine(playcount); }