static void Main(string[] args) { Console.WriteLine("Welcome to Rock Paper Scissors!"); Console.WriteLine("Enter your name: "); Human User = new Human(Console.ReadLine()); Console.WriteLine("Who would you like to play against? Rocko or Randy?"); Rocky Rocko = new Rocky("Rocko"); Rando Randy = new Rando("Randy"); bool a = true; while (a == true) { string answer1 = Console.ReadLine(); if (answer1.ToLower().Trim() == "rocko") { Play(Rocko, User); a = false; } else if (answer1.ToLower().Trim() == "randy") { Play(Randy, User); a = false; } else { Console.WriteLine("Sorry I didn't understand that. Do you want to play against Rocky or Rando?"); } } }
public void RoshamboAutomate() { //Allows user to pit Rocky and Creed against each other. Rocky rocky = new Rocky(); RandomOpponent creed = new RandomOpponent("Creed"); Console.WriteLine("How many fights would you like to simulate?"); string response = "error"; double fights = 0; while (response == "error") { response = Console.ReadLine(); try { fights = double.Parse(response); } catch (FormatException) { Console.WriteLine("Please input a proper integer."); response = "error"; } } Console.WriteLine("Simulating..."); for (int i = 0; i < fights; i++) { string result = Clash(creed, rocky); if (result == "draw") { Draws++; } else if (result == "loss") { Losses++; } else if (result == "win") { Wins++; } creed.Action = creed.GenerateRoshambo(); } //Exits application once simulation is complete Console.WriteLine("Simulation Complete."); Console.WriteLine("Rocky's final record vs Creed was: " + Wins + " Wins, " + Losses + " Losses, " + Draws + " Draws."); Console.WriteLine("Thanks for fighting!"); Environment.Exit(1); }
public string PlayerSelection(string answer) { if (answer == "r") { string npc1 = "Rocky"; Rocky r = new Rocky(npc1); return(r.generateRoShamBo()); } else if (answer == "d") { string npc1 = "Dwayne Johnson"; DwayneJohnson d = new DwayneJohnson(npc1); return(d.generateRoShamBo()); } else { return("Error"); } }
public RPSApp(Rocky r, HumanPick h) { this.r = r; this.h = h; }
static void Main(string[] args) { bool con = true; // Console.WriteLine(Enum.Paper);//cannot use .1 or [] Rocky r = new Rocky("Rock"); HumanPick h = new HumanPick("Dwayne Johnson"); RPSApp Y = new RPSApp(r, h); Random rando = new Random(); Random randy = new Random(); RandomPlayer rp = new RandomPlayer("Flaka", rando); RandomPlayer rpp = new RandomPlayer("Drin", randy); int counter = 0; int point = 0; while (con) { Console.WriteLine(); int num = rando.Next(1, 4); int num2 = randy.Next(1, 4); Console.WriteLine("Who do you want to play against?Flaka or Drin?"); string inputanswer = Console.ReadLine().ToLower(); if (inputanswer.Contains("Flaka") || inputanswer.Contains("flaka")) { string output = h.GetRPS(); string choice = rp.GetRPS(); Console.WriteLine("You chose: " + output); Console.WriteLine("Flaka Chose: " + choice); Console.WriteLine(); if ((output.Contains("Scissors")) && (choice.Contains("Scissors"))) { Console.WriteLine(); Console.WriteLine("It is a tie.You get 1 point"); counter = counter + 1; } else if ((output.Contains("Scissors")) && (choice.Contains("Paper"))) { Console.WriteLine(); Console.WriteLine("You win!.You get 2 points"); counter = counter + 2; } else if ((output.Contains("Scissors")) && (choice.Contains("Rock"))) { Console.WriteLine(); Console.WriteLine("You lose!.You get 0 points"); } else if ((output.Contains("Paper")) && (choice.Contains("Scissors"))) { Console.WriteLine(); Console.WriteLine("You lose.You get 0 points"); } else if ((output.Contains("Paper")) && (choice.Contains("Paper"))) { Console.WriteLine(); Console.WriteLine("It is a tie.You get 1 point"); counter = counter + 1; } else if ((output.Contains("Paper")) && (choice.Contains("Rock"))) { Console.WriteLine(); Console.WriteLine("You win!.You get 2 points"); counter = counter + 2; } else if ((output.Contains("Rock")) && (choice.Contains("Rock"))) { Console.WriteLine(); Console.WriteLine("It is a tie.You get 1 point"); counter = counter + 1; } else if ((output.Contains("Rock")) && (choice.Contains("Paper"))) { Console.WriteLine(); Console.WriteLine("You lose!.You get 0 points"); } else if ((output.Contains("Rock")) && (choice.Contains("Scissors"))) { Console.WriteLine(); Console.WriteLine("You win!.You get 2 points"); counter = counter + 2;//This is the endpoint } } if (inputanswer.Contains("Drin") || inputanswer.Contains("drin")) { string output = h.GetRPS(); Console.WriteLine("You chose: " + output); Console.WriteLine("Drin chose: " + rpp.GetRPS()); Console.WriteLine(); if ((output.Contains("Scissors")) && (rpp.GetRPS().Contains("Scissors"))) { Console.WriteLine(); Console.WriteLine("It is a tie.You get 1 point"); counter = counter + 1; } else if ((output.Contains("Scissors")) && (rpp.GetRPS().Contains("Paper"))) { Console.WriteLine(); Console.WriteLine("You win!.You get 2 points"); counter = counter + 2; } else if ((output.Contains("Scissors")) && (rpp.GetRPS().Contains("Rock"))) { Console.WriteLine(); Console.WriteLine("You lose!.You get 0 points"); } else if ((output.Contains("Paper")) && (rpp.GetRPS().Contains("Scissors"))) { Console.WriteLine(); Console.WriteLine("You lose.You get 0 points"); } else if ((output.Contains("Paper")) && (rpp.GetRPS().Contains("Paper"))) { Console.WriteLine(); Console.WriteLine("It is a tie.You get 1 point"); counter = counter + 1; } else if ((output.Contains("Paper")) && (rpp.GetRPS().Contains("Rock"))) { Console.WriteLine(); Console.WriteLine("You win!.You get 2 points"); counter = counter + 2; } else if ((output.Contains("Rock")) && (rpp.GetRPS().Contains("Rock"))) { Console.WriteLine(); Console.WriteLine("It is a tie.You get 1 point"); counter = counter + 1; } else if ((output.Contains("Rock")) && (rpp.GetRPS().Contains("Paper"))) { Console.WriteLine(); Console.WriteLine("You lose!.You get 0 points"); } else if ((output.Contains("Rock")) && (rpp.GetRPS().Contains("Scissors"))) { Console.WriteLine(); Console.WriteLine("You win!.You get 2 points"); counter = counter + 2; } } Console.WriteLine("Your points are: " + counter); Console.WriteLine("Do you want to continue?"); string answer = Console.ReadLine().ToLower(); if (answer == "y") { con = true; point = point + counter; } else { con = false; Console.WriteLine("Thank you for playing.Your total points are: " + point); } } }