Exemplo n.º 1
0
        public static void PartB(string strTournament)
        {
            try
            {
                GameRPS game = new GameRPS();
                string[,,] tournament = JsonConvert.DeserializeObject <string[, , ]>(strTournament.Remove(strTournament.Length - 1).Remove(0, 1));

                string[] PlayerWinner = game.Rps_tournament_winner(tournament);
                Console.WriteLine($"Winner Name [{PlayerWinner[0]}] Move [{PlayerWinner[1]?.ToUpper()}]");
            }
            catch (WrongNumberOfPlayersError ex)
            {
                Console.WriteLine($"Error #{ex.Message}");
            }
            catch (NoSuchStrategyError ex)
            {
                Console.WriteLine($"Error #{ex.Message}");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error #{ex.Message}");
            }
        }
Exemplo n.º 2
0
        public static void PartA(string strGame)
        {
            try
            {
                GameRPS game = new GameRPS();
                string[,] elements = JsonConvert.DeserializeObject <string[, ]>(strGame);

                string[] PlayerWinner = game.Rps_game_winner(elements);
                Console.WriteLine($"Winner Name [{PlayerWinner[0]}] Move [{PlayerWinner[1]?.ToUpper()}]");
            }
            catch (WrongNumberOfPlayersError ex)
            {
                Console.WriteLine($"Error #{ex.Message}");
            }
            catch (NoSuchStrategyError ex)
            {
                Console.WriteLine($"Error #{ex.Message}");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error #{ex.Message}");
            }
        }