public static Game rps_game_winner(List <Game> games) //Part A { if (games.Count == 2) { for (int i = 0; i < games.Count; i++) { if (Validations.ValidPlayer(games[i].Player) && Validations.ValidMove(games[i].Move)) { if (i == games.Count - 1) { return(WinnerPlayer.Winner(games)); } } else { throw new System.ArgumentException("NoSuchStrategyError"); } } throw new System.ArgumentException("NoSuchStrategyError"); } else { throw new System.ArgumentException("WrongNumberOfPlayersError"); } }
public static Game rps_tournament_winner(List <Game> list) // Part B { int i = 0; int listInt = list.Count; List <Game> listWinners = new List <Game>(); while (list.Count != 1) { listWinners.Add(WinnerPlayer.Winner(list)); list.Remove(list[i]); listInt = list.Count; if (listInt == 0) { listInt = listWinners.Count; list = listWinners; listWinners = new List <Game>(); } } return(list[0]); }