Write an application with following method to resolve two player game of Rock-Paper-Scissors. rockPaperScissors method takes two parameters: a string representing a first player's move in a game of Rock-Paper-Scissors and a string representing a second player's move. Depending on each player's move, the function should output to the console the winner of the round if there was a winner, a tie if both players had the same move, or whether a player gave an invalid move. When comparing moves, letter-casing does not matter ("rock" should be considered the same move as "rOcK"). The two-player game of Rock-Paper-Scissors works as following: Each player chooses one of three moves: "rock", "paper", or "scissors". A move of "rock" wins over another player's move of "scissors". A move of "scissors" wins over another player's move of "paper". A move of "paper" wins over another player's move of "rock". If two players use the same move, the result is a tie For example, a call of rockPaperScissors("rock", "scissors") would result in console output of "Player 1 wins!". A call of rockPaperScissors("ROCK", "Paper") would result in console output of "Player 2 wins!". A call of rockPaperScissors("SCISSORS", "Scissors") would result in console output of "TIE!". If one player gives a move other than "rock", "paper", or "scissors", the console output should be "Invalid move of [player's invalid move]!", where you should replace [player's invalid move] with the exact value passed by that player. If both players pass invalid moves, the console output should be "Invalid moves of [player 1's invalid move] and [player 2's invalid move]!".
Write an application with following method to resolve two player game of Rock-Paper-Scissors. rockPaperScissors method takes two parameters: a string representing a first player's move in a game of Rock-Paper-Scissors and a string representing a second player's move. Depending on each player's move, the function should output to the console the winner of the round if there was a winner, a tie if both players had the same move, or whether a player gave an invalid move. When comparing moves, letter-casing does not matter ("rock" should be considered the same move as "rOcK"). The two-player game of Rock-Paper-Scissors works as following: Each player chooses one of three moves: "rock", "paper", or "scissors". A move of "rock" wins over another player's move of "scissors". A move of "scissors" wins over another player's move of "paper". A move of "paper" wins over another player's move of "rock". If two players use the same move, the result is a tie For example, a call of rockPaperScissors("rock", "scissors") would result in console output of "Player 1 wins!". A call of rockPaperScissors("ROCK", "Paper") would result in console output of "Player 2 wins!". A call of rockPaperScissors("SCISSORS", "Scissors") would result in console output of "TIE!". If one player gives a move other than "rock", "paper", or "scissors", the console output should be "Invalid move of [player's invalid move]!", where you should replace [player's invalid move] with the exact value passed by that player. If both players pass invalid moves, the console output should be "Invalid moves of [player 1's invalid move] and [player 2's invalid move]!".
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 4 images