public HandSign GetUserInputHandSign() { Console.WriteLine("What hand sign do you want to choose?"); HandSign GetHandSign = new HandSign(Console.ReadLine()); Console.WriteLine(GetHandSign); return GetHandSign; }
public Player(string name, HandSign chosenHandSign,int playerWins,int playerLoss) { this.name = name; this.currentHandSign = chosenHandSign; this.playerCurrentWins = playerWins; this.playerCurrentLoss = playerLoss; }
public Player(string name, HandSign chosenHandSign, int playerWins, int playerLoss) { this.name = name; this.currentHandSign = chosenHandSign; this.playerCurrentWins = playerWins; this.playerCurrentLoss = playerLoss; }
public HandSign GetUserInputHandSign() { Console.WriteLine("What hand sign do you want to choose?"); HandSign GetHandSign = new HandSign(Console.ReadLine()); Console.WriteLine(GetHandSign); return(GetHandSign); }
public HandSign ChooseHandSign() { //Accept user input in various ways Console.WriteLine("R-Rock\n" + "P-Paper\n " + "S-Scissors\n" + "Make your selection:"); string input = Console.ReadLine(); var handSign = HandSign.MapStringToMove(input); if (handSign == null) { Console.WriteLine("Sorry Invalid. Please choose again"); return(ChooseHandSign()); } return(handSign); }
static void Main(string[] args) { int player1Wins=0; int player2Wins=0; int player1Loss=0; int player2Loss=0; string player1Name; string player2Name; string AI = "AI"; string human = "human"; Console.WriteLine("playign against AI or human?"); String chosenOponent = (Console.ReadLine()); if (chosenOponent=="Human") { GetHandSign newHandSign = new GetHandSign(null); HandSign handSign = new HandSign(null); CompairHandSignChoises chosensigns = new CompairHandSignChoises(); Player player1 = new Player("Adam", handSign.GetUserInputHandSign(), player1Wins, player1Loss); Player player2 = new Player("fred", handSign.GetUserInputHandSign(), player2Wins, player2Loss); Console.WriteLine("player1 chose " + player1.currentHandSign.chosenSign); Console.WriteLine("player2 chose {0}", player2.currentHandSign.chosenSign); chosensigns.CompairHandSigns(player1.currentHandSign, player2.currentHandSign); } else if (chosenOponent=="AI") { Random RandomNumber = new Random(); int AIHandSign = RandomNumber.Next(5); GetHandSign newHandSign = new GetHandSign(null); HandSign handSign = new HandSign(null); CompairHandSignChoises chosensigns = new CompairHandSignChoises(); Player player1 = new Player("Adam", handSign.GetUserInputHandSign(), player1Wins, player1Loss); Player player2 = new Player("fred", handSign.GetAIHandSign(AIHandSign), player2Wins, player2Loss); Console.WriteLine("player1 chose "+ player1.currentHandSign.chosenSign); Console.WriteLine("player2 chose {0}",player2.currentHandSign.chosenSign); } }
static void Main(string[] args) { int player1Wins = 0; int player2Wins = 0; int player1Loss = 0; int player2Loss = 0; string player1Name; string player2Name; string AI = "AI"; string human = "human"; Console.WriteLine("playign against AI or human?"); String chosenOponent = (Console.ReadLine()); if (chosenOponent == "Human") { GetHandSign newHandSign = new GetHandSign(null); HandSign handSign = new HandSign(null); CompairHandSignChoises chosensigns = new CompairHandSignChoises(); Player player1 = new Player("Adam", handSign.GetUserInputHandSign(), player1Wins, player1Loss); Player player2 = new Player("fred", handSign.GetUserInputHandSign(), player2Wins, player2Loss); Console.WriteLine("player1 chose " + player1.currentHandSign.chosenSign); Console.WriteLine("player2 chose {0}", player2.currentHandSign.chosenSign); chosensigns.CompairHandSigns(player1.currentHandSign, player2.currentHandSign); } else if (chosenOponent == "AI") { Random RandomNumber = new Random(); int AIHandSign = RandomNumber.Next(5); GetHandSign newHandSign = new GetHandSign(null); HandSign handSign = new HandSign(null); CompairHandSignChoises chosensigns = new CompairHandSignChoises(); Player player1 = new Player("Adam", handSign.GetUserInputHandSign(), player1Wins, player1Loss); Player player2 = new Player("fred", handSign.GetAIHandSign(AIHandSign), player2Wins, player2Loss); Console.WriteLine("player1 chose " + player1.currentHandSign.chosenSign); Console.WriteLine("player2 chose {0}", player2.currentHandSign.chosenSign); } }
public void startGame() { var name = printUtil.GreetOpponent(); //create players this.humanPlayer = new Player(name); this.cpuPlayer = new Player("CPU"); //start game message printUtil.StartGameMessage(humanPlayer); //Get users hand, Note check for valid entry var humanHandSign = printUtil.ChooseHandSign(); this.humanPlayer.HandSign = humanHandSign; //Generate a random hand for computer this.cpuPlayer.HandSign = HandSign.MapRandomToMove(); //compare choices //Declare winner Console.WriteLine(HandSign.GetWinner(this.humanPlayer, this.cpuPlayer)); //Give option to play again, do while loop run as long as true, }
public void CompairHandSigns(HandSign player1HandSign, HandSign player2HandSign) { if (player1HandSign is Rock && player2HandSign is Rock) { System.IO.File.WriteAllLines(@"C:\devcodecamp\devCodeCampProjects\RockPaperScissors\RockPaperScissors\RPSLS.tst", tie); Console.WriteLine("its a tie"); } else if (player1HandSign is Rock && player2HandSign is Paper) { System.IO.File.WriteAllLines(@"C:\devcodecamp\devCodeCampProjects\RockPaperScissors\RockPaperScissors\RPSLS.tst", p2Wins); Console.WriteLine("player2 wins"); } else if (player1HandSign is Rock && player2HandSign is Scissors) { System.IO.File.WriteAllLines(@"C:\devcodecamp\devCodeCampProjects\RockPaperScissors\RockPaperScissors\RPSLS.tst", p1Wins); Console.WriteLine("player1 wins"); } else if (player1HandSign is Rock && player2HandSign is Spock) { System.IO.File.WriteAllLines(@"C:\devcodecamp\devCodeCampProjects\RockPaperScissors\RockPaperScissors\RPSLS.tst", p2Wins); Console.WriteLine("player2 wins"); } else if (player1HandSign is Rock && player2HandSign is Lizard) { System.IO.File.WriteAllLines(@"C:\devcodecamp\devCodeCampProjects\RockPaperScissors\RockPaperScissors\RPSLS.tst", p1Wins); Console.WriteLine("player1 wins"); } else if (player1HandSign is Paper && player2HandSign is Paper) { System.IO.File.WriteAllLines(@"C:\devcodecamp\devCodeCampProjects\RockPaperScissors\RockPaperScissors\RPSLS.tst", tie); Console.WriteLine("Its a tie"); } else if (player1HandSign is Paper && player2HandSign is Rock) { System.IO.File.WriteAllLines(@"C:\devcodecamp\devCodeCampProjects\RockPaperScissors\RockPaperScissors\RPSLS.tst", p1Wins); Console.WriteLine("player1 wins"); } else if (player1HandSign is Paper && player2HandSign is Scissors) { System.IO.File.WriteAllLines(@"C:\devcodecamp\devCodeCampProjects\RockPaperScissors\RockPaperScissors\RPSLS.tst", p2Wins); Console.WriteLine("player2 wins"); } else if (player1HandSign is Paper && player2HandSign is Spock) { System.IO.File.WriteAllLines(@"C:\devcodecamp\devCodeCampProjects\RockPaperScissors\RockPaperScissors\RPSLS.tst", p1Wins); Console.WriteLine("player1 wins"); } else if (player1HandSign is Paper && player2HandSign is Lizard) { System.IO.File.WriteAllLines(@"C:\devcodecamp\devCodeCampProjects\RockPaperScissors\RockPaperScissors\RPSLS.tst", p2Wins); Console.WriteLine("player2 wins"); } else if (player1HandSign is Scissors && player2HandSign is Scissors) { System.IO.File.WriteAllLines(@"C:\devcodecamp\devCodeCampProjects\RockPaperScissors\RockPaperScissors\RPSLS.tst", tie); Console.WriteLine("Its a tie"); } else if (player1HandSign is Scissors && player2HandSign is Rock) { System.IO.File.WriteAllLines(@"C:\devcodecamp\devCodeCampProjects\RockPaperScissors\RockPaperScissors\RPSLS.tst", p2Wins); Console.WriteLine("player2 wins"); } else if (player1HandSign is Scissors && player2HandSign is Paper) { System.IO.File.WriteAllLines(@"C:\devcodecamp\devCodeCampProjects\RockPaperScissors\RockPaperScissors\RPSLS.tst", p1Wins); Console.WriteLine("player1 wins"); } else if (player1HandSign is Scissors && player2HandSign is Spock) { System.IO.File.WriteAllLines(@"C:\devcodecamp\devCodeCampProjects\RockPaperScissors\RockPaperScissors\RPSLS.tst", p2Wins); Console.WriteLine("player2 wins"); } else if (player1HandSign is Scissors && player2HandSign is Lizard) { System.IO.File.WriteAllLines(@"C:\devcodecamp\devCodeCampProjects\RockPaperScissors\RockPaperScissors\RPSLS.tst", p1Wins); Console.WriteLine("player1 wins"); } else if (player1HandSign is Lizard && player2HandSign is Lizard) { System.IO.File.WriteAllLines(@"C:\devcodecamp\devCodeCampProjects\RockPaperScissors\RockPaperScissors\RPSLS.tst", tie); Console.WriteLine("its a tie"); } else if (player1HandSign is Lizard && player2HandSign is Rock) { System.IO.File.WriteAllLines(@"C:\devcodecamp\devCodeCampProjects\RockPaperScissors\RockPaperScissors\RPSLS.tst", p2Wins); Console.WriteLine("player2 wins"); } else if (player1HandSign is Lizard && player2HandSign is Paper) { System.IO.File.WriteAllLines(@"C:\devcodecamp\devCodeCampProjects\RockPaperScissors\RockPaperScissors\RPSLS.tst", p1Wins); Console.WriteLine("player1 wins"); } else if (player1HandSign is Lizard && player2HandSign is Scissors) { System.IO.File.WriteAllLines(@"C:\devcodecamp\devCodeCampProjects\RockPaperScissors\RockPaperScissors\RPSLS.tst", p1Wins); Console.WriteLine("player2 wins"); } else if (player1HandSign is Lizard && player2HandSign is Spock) { System.IO.File.WriteAllLines(@"C:\devcodecamp\devCodeCampProjects\RockPaperScissors\RockPaperScissors\RPSLS.tst", p1Wins); Console.WriteLine("player1 wins"); } else if (player1HandSign is Spock && player2HandSign is Spock) { System.IO.File.WriteAllLines(@"C:\devcodecamp\devCodeCampProjects\RockPaperScissors\RockPaperScissors\RPSLS.tst", tie); Console.WriteLine("Its a tie"); } else if (player1HandSign is Spock && player2HandSign is Rock) { System.IO.File.WriteAllLines(@"C:\devcodecamp\devCodeCampProjects\RockPaperScissors\RockPaperScissors\RPSLS.tst", p1Wins); Console.WriteLine("player1 wins"); } else if (player1HandSign is Spock && player2HandSign is Paper) { System.IO.File.WriteAllLines(@"C:\devcodecamp\devCodeCampProjects\RockPaperScissors\RockPaperScissors\RPSLS.tst", p2Wins); Console.WriteLine("player2 wins"); } else if (player1HandSign is Spock && player2HandSign is Scissors) { System.IO.File.WriteAllLines(@"C:\devcodecamp\devCodeCampProjects\RockPaperScissors\RockPaperScissors\RPSLS.tst", p1Wins); Console.WriteLine("player1 wins"); } else if (player1HandSign is Spock && player2HandSign is Lizard) { System.IO.File.WriteAllLines(@"C:\devcodecamp\devCodeCampProjects\RockPaperScissors\RockPaperScissors\RPSLS.tst", p2Wins); Console.WriteLine("player2 wins"); } }