[chore:] struct improvements and default-course-importer
This commit is contained in:
67
structs.cs
67
structs.cs
@@ -1,32 +1,56 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Avalonia.Data;
|
||||||
|
|
||||||
namespace spplus;
|
namespace spplus;
|
||||||
|
|
||||||
public class Sport
|
public class Sport
|
||||||
{
|
{
|
||||||
|
public int ID { get; set; } = 0;
|
||||||
public string Name { get; set; } = "Neuer Kurs"; // Kursname
|
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 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<string> AlternativeNames { get; set; } = new();
|
||||||
|
public List<int> AlternativeCourses { get; set; } = new();
|
||||||
|
|
||||||
protected Sport()
|
protected Sport()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Sport(string name)
|
public Sport(string name)
|
||||||
{
|
{
|
||||||
Name = 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<string> alternativeNames)
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = name;
|
||||||
MaxCoursesPerSemester = maxCoursesPerSemester;
|
|
||||||
MaxStudents = maxStudents;
|
MaxStudents = maxStudents;
|
||||||
MinStudents = minStudents;
|
MinStudents = minStudents;
|
||||||
Semester = semester;
|
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<Student> Students { get; set; } = [];
|
public List<Student> Students { get; set; } = [];
|
||||||
public List<Sport> Sports { get; set; } = [];
|
public List<Sport> Sports { get; set; } = [];
|
||||||
|
public int NumCoursesPerSemester { get; set; } = 10;
|
||||||
|
|
||||||
public Settings()
|
public Settings()
|
||||||
{
|
{
|
||||||
@@ -72,4 +97,34 @@ public class Settings
|
|||||||
{
|
{
|
||||||
// Hier importieren...
|
// 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user