50% completed
This commit is contained in:
parent
05b56150b1
commit
c45770085e
3 changed files with 55 additions and 8 deletions
|
|
@ -52,7 +52,14 @@ public static class QualData
|
|||
/// <returns>True if the value is found; false otherwise</returns>
|
||||
public static bool IsContained(string value, string[] possibleValues)
|
||||
{
|
||||
// TODO
|
||||
foreach (var possibleValue in possibleValues)
|
||||
{
|
||||
if (possibleValue.ToLower() == value.ToLower())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -77,8 +84,17 @@ public static class QualData
|
|||
/// <returns>Array of matches in which the supplied country participated</returns>
|
||||
public static Match[] FilterMatchesByCountry(Match[] allMatches, string countryName)
|
||||
{
|
||||
// TODO
|
||||
return [];
|
||||
Match[] filteredMatches = [];
|
||||
foreach (var match in allMatches)
|
||||
{
|
||||
if (IsCountryMatch(match, countryName))
|
||||
{
|
||||
filteredMatches = filteredMatches.Append(match).ToArray();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return filteredMatches;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -89,8 +105,9 @@ public static class QualData
|
|||
/// <returns>True if the country participated in the match; false otherwise</returns>
|
||||
public static bool IsCountryMatch(Match match, string countryName)
|
||||
{
|
||||
// TODO
|
||||
return false;
|
||||
TeamResult homeTeam = match.HomeTeam;
|
||||
TeamResult guestTeam = match.GuestTeam;
|
||||
return homeTeam.TeamName == countryName || guestTeam.TeamName == countryName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -99,7 +116,12 @@ public static class QualData
|
|||
/// <param name="matches">Array of matches to print</param>
|
||||
private static void PrintMatches(Match[] matches)
|
||||
{
|
||||
// TODO
|
||||
foreach (var match in matches)
|
||||
{
|
||||
TeamResult homeTeam = match.HomeTeam;
|
||||
TeamResult guestTeam = match.GuestTeam;
|
||||
Console.WriteLine($"{homeTeam.TeamName} {homeTeam.Goals} - {guestTeam.Goals} {guestTeam.TeamName}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -111,7 +133,13 @@ public static class QualData
|
|||
/// <returns>The name of the country the user selected</returns>
|
||||
private static string AskForCountry(string[] possibleCountries)
|
||||
{
|
||||
// TODO
|
||||
return string.Empty;
|
||||
string country;
|
||||
do
|
||||
{
|
||||
Console.Write("Enter country: ");
|
||||
country = Console.ReadLine()!.ToLower();
|
||||
} while (!IsContained(country!, possibleCountries));
|
||||
|
||||
return country;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue