Projektdateien hinzufügen.
This commit is contained in:
parent
72ecb03642
commit
76fbb232a7
48 changed files with 3779 additions and 0 deletions
41
BusinessLogic/Helpers.cs
Normal file
41
BusinessLogic/Helpers.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue