static void Main(string[] args) { var john = new Player1(0); var dana = new Player2(0); var josie = new Player3(0); var theGame = new Game(); for (int i = 0; i < 100; i++) { var rnd = new Random(); int value = rnd.Next(7); switch (value) { case 1: Console.WriteLine("Round " + i + " " + john.Act() + " VS " + dana.Act() + " -----> WINNER: " + (theGame.Fight(john, dana)).Act()); break; case 2: Console.WriteLine("Round " + i + " " + john.Act() + " VS " + josie.Act() + " -----> WINNER: " + (theGame.Fight(john, josie)).Act()); break; default: Console.WriteLine("Round " + i + " " + dana.Act() + " VS " + josie.Act() + " -----> WINNER: " + (theGame.Fight(dana, josie)).Act()); break; } } Console.WriteLine("Rock Number of Wins = " + john.NumOfWins); int rockWins = john.NumOfWins; Console.WriteLine("Paper Number of Wins = " + dana.NumOfWins); int paperWins = dana.NumOfWins; Console.WriteLine("Scissors Number of Wins = " + josie.NumOfWins); int scissorsWins = josie.NumOfWins; if (rockWins > paperWins && rockWins > scissorsWins) { Console.WriteLine("Rock Wins with total of: " + john.NumOfWins); } else if (paperWins > rockWins && paperWins > scissorsWins) { Console.WriteLine("Paper Wins with total of: " + dana.NumOfWins); } else { Console.WriteLine("Scissors Wins with total of: " + josie.NumOfWins); } Console.Read(); }
static void Main(string[] args) { var john = new Player1(0); var dana = new Player2(0); var josie = new Player3(0); var theGame = new Game(); for(int i = 0; i < 100; i++) { var rnd = new Random(); int value = rnd.Next(7); switch (value) { case 1: Console.WriteLine("Round " + i + " " + john.Act() + " VS " + dana.Act() + " -----> WINNER: " + (theGame.Fight(john, dana)).Act()); break; case 2: Console.WriteLine("Round " + i + " " + john.Act() + " VS " + josie.Act() + " -----> WINNER: " + (theGame.Fight(john, josie)).Act()); break; default: Console.WriteLine("Round " + i + " " + dana.Act() + " VS " + josie.Act() + " -----> WINNER: " + (theGame.Fight(dana, josie)).Act()); break; } } Console.WriteLine("Rock Number of Wins = " + john.NumOfWins); int rockWins = john.NumOfWins; Console.WriteLine("Paper Number of Wins = " + dana.NumOfWins); int paperWins = dana.NumOfWins; Console.WriteLine("Scissors Number of Wins = " + josie.NumOfWins); int scissorsWins = josie.NumOfWins; if(rockWins > paperWins && rockWins > scissorsWins) { Console.WriteLine("Rock Wins with total of: " + john.NumOfWins); } else if (paperWins > rockWins && paperWins > scissorsWins) { Console.WriteLine("Paper Wins with total of: " + dana.NumOfWins); } else { Console.WriteLine("Scissors Wins with total of: " + josie.NumOfWins); } Console.Read(); }
public void RunApp() { Console.WriteLine("Enter your name"); string name = Console.ReadLine(); Console.WriteLine("Would you like to play against player 1 or player 2(enter 1 for player 1, 2 for player 2): "); int userChoice; userChoice = IsValidIntEntered(Console.ReadLine()); char loopBreaker; int userPlayerWins = 0; int compPlayerWins = 0; do { if (userChoice == 1) { Console.WriteLine("Rock, Paper, Scissors: (1 = rock, 2 = paper, 3 = scissors)"); string choice = Console.ReadLine(); UserPlayer user = new UserPlayer(name, choice); Player1 compPlayer = new Player1(); if (user.RoshamboValue == Roshambo.rock) { Console.WriteLine($"{user.Name}: {user.RoshamboValue}"); Console.WriteLine($"{compPlayer.Name}: {compPlayer.RoshamboValue}"); Console.WriteLine("Neither player wins draw"); } else if (user.RoshamboValue == Roshambo.paper) { Console.WriteLine($"{user.Name}: {user.RoshamboValue}"); Console.WriteLine($"{compPlayer.Name}: {compPlayer.RoshamboValue}"); Console.WriteLine($"{user.Name} wins"); userPlayerWins++; } else { Console.WriteLine($"{user.Name}: {user.RoshamboValue}"); Console.WriteLine($"{compPlayer.Name}: {compPlayer.RoshamboValue}"); Console.WriteLine($"{compPlayer.Name} wins"); compPlayerWins++; } Console.ReadLine(); } else { Console.WriteLine("Rock, Paper, Scissors: (1 = rock, 2 = paper, 3 = scissors)"); string choice = Console.ReadLine(); UserPlayer user = new UserPlayer(name, choice); Player2 compPlayer = new Player2(); Player3 playerResult = new Player3(); compPlayer.RoshamboValue = playerResult.RoshamboChoice(compPlayer); if (user.RoshamboValue == Roshambo.rock) { if (compPlayer.RoshamboValue == Roshambo.rock) { Console.WriteLine($"{user.Name}: {user.RoshamboValue}"); Console.WriteLine($"{compPlayer.Name}: {compPlayer.RoshamboValue}"); Console.WriteLine("Its a tie!"); } else if (compPlayer.RoshamboValue == Roshambo.paper) { Console.WriteLine($"{user.Name}: {user.RoshamboValue}"); Console.WriteLine($"{compPlayer.Name}: {compPlayer.RoshamboValue}"); Console.WriteLine("Player 2 wins!"); compPlayerWins++; } else { Console.WriteLine($"{user.Name}: {user.RoshamboValue}"); Console.WriteLine($"{compPlayer.Name}: {compPlayer.RoshamboValue}"); Console.WriteLine($"{user.Name} wins!"); userPlayerWins++; } } else if (user.RoshamboValue == Roshambo.paper) { if (compPlayer.RoshamboValue == Roshambo.rock) { Console.WriteLine($"{user.Name}: {user.RoshamboValue}"); Console.WriteLine($"{compPlayer.Name}: {compPlayer.RoshamboValue}"); Console.WriteLine($"{user.Name} wins!"); userPlayerWins++; } else if (compPlayer.RoshamboValue == Roshambo.paper) { Console.WriteLine($"{user.Name}: {user.RoshamboValue}"); Console.WriteLine($"{compPlayer.Name}: {compPlayer.RoshamboValue}"); Console.WriteLine("Its a tie!"); } else { Console.WriteLine($"{user.Name}: {user.RoshamboValue}"); Console.WriteLine($"{compPlayer.Name}: {compPlayer.RoshamboValue}"); Console.WriteLine("Player 2 wins!"); compPlayerWins++; } } else { if (compPlayer.RoshamboValue == Roshambo.rock) { Console.WriteLine($"{user.Name}: {user.RoshamboValue}"); Console.WriteLine($"{compPlayer.Name}: {compPlayer.RoshamboValue}"); Console.WriteLine("Player 2 wins!"); compPlayerWins++; } else if (compPlayer.RoshamboValue == Roshambo.paper) { Console.WriteLine($"{user.Name}: {user.RoshamboValue}"); Console.WriteLine($"{compPlayer.Name}: {compPlayer.RoshamboValue}"); Console.WriteLine($"{user.Name} wins!"); userPlayerWins++; } else { Console.WriteLine($"{user.Name}: {user.RoshamboValue}"); Console.WriteLine($"{compPlayer.Name}: {compPlayer.RoshamboValue}"); Console.WriteLine("Its a tie!"); } } } Console.WriteLine("Do you wish to continue(enter y/n): "); //ask user to if they want to continue loopBreaker = IsValidLoopBreaker(Console.ReadLine()); //storing answer and if it's valid input Console.ReadLine(); } while (loopBreaker == 'y'); Console.WriteLine($"{name} won {userPlayerWins} games"); Console.WriteLine($"{name} lost {compPlayerWins} games"); }