using System.Collections.Generic;
public static void Main()
Console.WriteLine("Jo Ken Po - v0.1");
var player1 = FetchPlay(1);
var player2 = FetchPlay(2);
var result = GetMessage(JoKenPo.Play(player1, player2));
Console.WriteLine(result);
private static JoKenPoPlay FetchPlay(int playerNumber)
Console.WriteLine("Insira a jogada do Player " + playerNumber);
var playersChoice = Console.ReadLine();
if (Enum.TryParse(playersChoice, out JoKenPoPlay play))
Console.WriteLine("opção inválida");
throw new Exception("an error has occured.");
private static string GetMessage(JoKenPoResult result) => result switch
JoKenPoResult.Draw => "Empate!",
JoKenPoResult.Player1 => "O Player 1 ganhou!!",
JoKenPoResult.Player2 => "O Player 2 ganhou!!",
public static class JoKenPo
private static Dictionary<JoKenPoPlay, JoKenPoPlay> winningPlays = new Dictionary<JoKenPoPlay, JoKenPoPlay>()
{ JoKenPoPlay.Rock, JoKenPoPlay.Scissor },
{ JoKenPoPlay.Paper, JoKenPoPlay.Rock },
{ JoKenPoPlay.Scissor, JoKenPoPlay.Paper }
public static JoKenPoResult Play(JoKenPoPlay playerOne, JoKenPoPlay playerTwo)
if (playerOne == playerTwo)
return JoKenPoResult.Draw;
if (winningPlays[playerOne] == playerTwo)
return JoKenPoResult.Player1;
return JoKenPoResult.Player2;
public enum JoKenPoResult