diff --git a/.idea/.idea.EM-Qual/.idea/discord.xml b/.idea/.idea.EM-Qual/.idea/discord.xml new file mode 100644 index 0000000..104c42f --- /dev/null +++ b/.idea/.idea.EM-Qual/.idea/discord.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/EM-Qual/QualData.cs b/EM-Qual/QualData.cs index ca19900..09e4072 100644 --- a/EM-Qual/QualData.cs +++ b/EM-Qual/QualData.cs @@ -38,9 +38,34 @@ public static class QualData /// True if the line could be parsed successfully; false otherwise public static bool TryParseMatch(string line, out Match? match) { - // TODO match = null; - return false; + + string[] parts = line.Split(';'); + if (parts.Length != 4) + { + return false; + } + + foreach (var part in parts) + { + if (part.Length == 0) + { + return false; + } + } + + int[] goals = new int[2]; + if (!int.TryParse(parts[2], out goals[0]) || !int.TryParse(parts[3], out goals[1])) + { + return false; + } + if(goals[0] < 0 || goals[1] < 0) + { + return false; + } + + match = new Match(new TeamResult(parts[0], goals[0]), new TeamResult(parts[1], goals[1])); + return true; } /// @@ -71,8 +96,22 @@ public static class QualData /// An array of unique country names public static string[] ExtractUniqueCountryNames(Match[] matches) { - // TODO - return []; + string[] countryNames = []; + foreach (var match in matches) + { + TeamResult homeTeam = match.HomeTeam; + TeamResult guestTeam = match.GuestTeam; + if (!IsContained(homeTeam.TeamName, countryNames)) + { + countryNames = countryNames.Append(homeTeam.TeamName).ToArray(); + } + if (!IsContained(guestTeam.TeamName, countryNames)) + { + countryNames = countryNames.Append(guestTeam.TeamName).ToArray(); + } + } + + return countryNames; } ///