ReadMatchesFromFile not implemented

The rest is done, and it's unit tests are green
This commit is contained in:
MarcUs7i 2024-09-12 19:05:02 +02:00
parent c45770085e
commit 90ff129e06
2 changed files with 57 additions and 4 deletions

14
.idea/.idea.EM-Qual/.idea/discord.xml generated Normal file
View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DiscordProjectSettings">
<option name="show" value="ASK" />
<option name="description" value="" />
<option name="applicationTheme" value="default" />
<option name="iconsTheme" value="default" />
<option name="button1Title" value="" />
<option name="button1Url" value="" />
<option name="button2Title" value="" />
<option name="button2Url" value="" />
<option name="customApplicationId" value="" />
</component>
</project>

View file

@ -38,9 +38,34 @@ public static class QualData
/// <returns>True if the line could be parsed successfully; false otherwise</returns>
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;
}
/// <summary>
@ -71,8 +96,22 @@ public static class QualData
/// <returns>An array of unique country names</returns>
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;
}
/// <summary>