Projektdateien hinzufügen.

This commit is contained in:
Kevin Kandlbinder 2024-06-21 13:11:34 +02:00
parent 72ecb03642
commit 76fbb232a7
48 changed files with 3779 additions and 0 deletions

41
BusinessLogic/Helpers.cs Normal file
View file

@ -0,0 +1,41 @@

namespace WebEMSim
{
internal class Helpers
{
public static T GetRandomFromList<T>(List<T> list)
{
return list[Random.Shared.Next(list.Count)];
}
public static T GetRandomFromListAndRemove<T>(List<T> list)
{
T chosenOne = GetRandomFromList(list);
list.Remove(chosenOne);
return chosenOne;
}
public static List<Match> GenerateMatches(List<Team> teams)
{
List<Match> matches = [];
for (int teamAIdx = 0; teamAIdx < teams.Count - 1; teamAIdx++)
{
for (int teamBIdx = teamAIdx + 1; teamBIdx < teams.Count; teamBIdx++)
{
matches.Add(new Match(teams[teamAIdx], teams[teamBIdx]));
}
}
return matches.OrderBy(x => Random.Shared.Next()).ToList(); // why x ??
}
public static char NumberToLetter(int number)
{
return (char)(number+0x41);
}
}
}