Initial commit
This commit is contained in:
commit
612509ac25
18 changed files with 4614 additions and 0 deletions
117
EM-Qual/QualData.cs
Normal file
117
EM-Qual/QualData.cs
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
namespace EMQual;
|
||||
|
||||
public static class QualData
|
||||
{
|
||||
/// <summary>
|
||||
/// Executes the <see cref="QualData"/> program.
|
||||
/// </summary>
|
||||
public static void Run()
|
||||
{
|
||||
var matches = ReadMatchesFromFile("Data/matches.csv");
|
||||
PrintMatches(matches);
|
||||
Console.WriteLine();
|
||||
|
||||
var countryNames = ExtractUniqueCountryNames(matches);
|
||||
var selCountry = AskForCountry(countryNames);
|
||||
var countryMatches = FilterMatchesByCountry(matches, selCountry);
|
||||
PrintMatches(countryMatches);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads match information from a CSV file at the provided location.
|
||||
/// If the file does not exist or does not contain relevant or some
|
||||
/// corrupted data an empty array is returned.
|
||||
/// </summary>
|
||||
/// <param name="filePath">The relative path to the CSV file</param>
|
||||
/// <returns>An array containing parsed match data records</returns>
|
||||
public static Match[] ReadMatchesFromFile(string filePath)
|
||||
{
|
||||
// TODO
|
||||
return [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to parse a line with semicolon separated data for a match.
|
||||
/// </summary>
|
||||
/// <param name="line">Line to parse</param>
|
||||
/// <param name="match">Parsed match object; null if parsing fails</param>
|
||||
/// <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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the supplied string is contained in the provided array of strings.
|
||||
/// Case is ignored.
|
||||
/// </summary>
|
||||
/// <param name="value">Value to check for</param>
|
||||
/// <param name="possibleValues">Array of values to check in</param>
|
||||
/// <returns>True if the value is found; false otherwise</returns>
|
||||
public static bool IsContained(string value, string[] possibleValues)
|
||||
{
|
||||
// TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an array containing the names of all countries which have participated
|
||||
/// in at least one match exactly one time.
|
||||
/// </summary>
|
||||
/// <param name="matches">Array of all matches played</param>
|
||||
/// <returns>An array of unique country names</returns>
|
||||
public static string[] ExtractUniqueCountryNames(Match[] matches)
|
||||
{
|
||||
// TODO
|
||||
return [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new array of matches, based on the supplied full collection, but
|
||||
/// with filtered to only contain matches the provided country participated in.
|
||||
/// </summary>
|
||||
/// <param name="allMatches">Array of all matches played</param>
|
||||
/// <param name="countryName">Name of the country to filter for</param>
|
||||
/// <returns>Array of matches in which the supplied country participated</returns>
|
||||
public static Match[] FilterMatchesByCountry(Match[] allMatches, string countryName)
|
||||
{
|
||||
// TODO
|
||||
return [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the supplied match is one the provided country participated in.
|
||||
/// </summary>
|
||||
/// <param name="match">Match to check</param>
|
||||
/// <param name="countryName">Country for which to check</param>
|
||||
/// <returns>True if the country participated in the match; false otherwise</returns>
|
||||
public static bool IsCountryMatch(Match match, string countryName)
|
||||
{
|
||||
// TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prints the matches to the terminal.
|
||||
/// </summary>
|
||||
/// <param name="matches">Array of matches to print</param>
|
||||
private static void PrintMatches(Match[] matches)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asks the user to enter a country to filter for.
|
||||
/// The user can only enter one of the existing countries. Case is not relevant.
|
||||
/// If the user enters something invalid the input request is retried until the user gets it right.
|
||||
/// </summary>
|
||||
/// <param name="possibleCountries">Array containing the names of possible countries to pick from</param>
|
||||
/// <returns>The name of the country the user selected</returns>
|
||||
private static string AskForCountry(string[] possibleCountries)
|
||||
{
|
||||
// TODO
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue