From 5868ca882b4d90d51b011cd7928c3a770b8ae7f2 Mon Sep 17 00:00:00 2001 From: Elias Fierke Date: Fri, 27 Feb 2026 11:07:32 +0100 Subject: [PATCH] [chore:] struct improvements and default-course-importer --- structs.cs | 67 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 6 deletions(-) diff --git a/structs.cs b/structs.cs index 8bca1a5..3d36f8e 100644 --- a/structs.cs +++ b/structs.cs @@ -1,32 +1,56 @@ using System.Collections.Generic; +using Avalonia.Data; namespace spplus; public class Sport { + public int ID { get; set; } = 0; public string Name { get; set; } = "Neuer Kurs"; // Kursname - public int MaxCoursesPerSemester { get; set; } = 1; // Maximale Anzahl an Kursen pro Semester - public int MaxStudents { get; set; } = 20; // Maximale Anzahl an Schülern pro Kurs + + public int MaxStudents { get; set; } = 25; // Maximale Anzahl an Schülern pro Kurs public int MinStudents { get; set; } = 5; // Minimale Anzahl an Schülern pro Kurs - public int[] Semester { get; set; } = [1, 2, 3, 4]; // Angebot in diesen Semestern + public int[] Semester { get; set; } = [2, 2, 2, 2]; // Maximale Anzahl an Angeboten in den jeweiligen Index-Semestern (0 => 1. Semester) + public List AlternativeNames { get; set; } = new(); + public List AlternativeCourses { get; set; } = new(); protected Sport() { } - protected Sport(string name) + public Sport(string name) { Name = name; } - protected Sport(string name, int maxCoursesPerSemester, int maxStudents, int minStudents, int[] semester) + public Sport(string name, int maxCoursesPerSemester, int maxStudents, int minStudents, int[] semester, List alternativeNames) { Name = name; - MaxCoursesPerSemester = maxCoursesPerSemester; MaxStudents = maxStudents; MinStudents = minStudents; Semester = semester; + AlternativeNames = alternativeNames; + } + + public void AddAlternativeSport(int id) + { + AlternativeCourses.Add(id); + } + + public void ClearAlternativeSport() + { + AlternativeCourses.Clear(); + } + + public override string ToString() + { + var alt = ""; + foreach (var s in AlternativeNames) + { + alt += s + ", "; + } + return $"{Name} ({alt})"; } } @@ -62,6 +86,7 @@ public class Settings public List Students { get; set; } = []; public List Sports { get; set; } = []; + public int NumCoursesPerSemester { get; set; } = 10; public Settings() { @@ -72,4 +97,34 @@ public class Settings { // Hier importieren... } + + public static void ImportInitial() + { + Instance.Sports.Add(new Sport("Tischtennis"){ AlternativeNames = {"Sport_TT"}}); + Instance.Sports.Add(new Sport("Badminton"){ AlternativeNames = {"Sport_BM"}}); + Instance.Sports.Add(new Sport("Gynmastik/Tanz"){ AlternativeNames = {"Sport_Gym"}}); + Instance.Sports.Add(new Sport("Schwimmen"){ AlternativeNames = {"Sport_SW"}, Semester = [1, 1, 1, 1], MaxStudents = 18}); + Instance.Sports.Add(new Sport("Bouldern"){ AlternativeNames = {"Sport_BO"}, Semester = [1, 1, 1, 1]}); + Instance.Sports.Add(new Sport("Basketball"){ AlternativeNames = {"Sport_BS"}}); + Instance.Sports.Add(new Sport("Fitness"){ AlternativeNames = {"Sport_Fit"}}); + Instance.Sports.Add(new Sport("Fußball"){ AlternativeNames = {"Sport_Fuß"}, Semester = [1, 0, 1, 0]}); + Instance.Sports.Add(new Sport("Handball"){ AlternativeNames = {"Sport_HB"}}); + Instance.Sports.Add(new Sport("Leichtathletik"){ AlternativeNames = {"Sport_LA"}, Semester = [1, 0, 1, 0], MaxStudents = 18}); + Instance.Sports.Add(new Sport("Tennis"){ AlternativeNames = {"Sport_Te"}}); + Instance.Sports.Add(new Sport("Turnen"){ AlternativeNames = {"Sport_Tur"}}); + Instance.Sports.Add(new Sport("Volleyball"){ AlternativeNames = {"Sport_VB"}}); + } + + public static string? GetSportNameFromID(int id) + { + foreach (var s in Instance.Sports) + { + if (s.ID == id) + { + return s.Name; + } + } + + return null; + } } \ No newline at end of file