Add a TimeSlot object, refactor
This commit is contained in:
@@ -4,11 +4,18 @@ namespace Core.Calculation;
|
||||
|
||||
public class TeamSchedulerSolution(
|
||||
Team[][] timeSlots,
|
||||
Student[] students,
|
||||
string status)
|
||||
{
|
||||
public Team[][] TimeSlots { get; set; } = timeSlots;
|
||||
public string Status { get; set; } = status;
|
||||
public string Status { get; } = status;
|
||||
|
||||
public TeamScheduleTimeSlot[] TimeSlots { get; set; }
|
||||
= timeSlots.Select( (teams,i) =>
|
||||
new TeamScheduleTimeSlot{Name = i.ToString(), Teams = teams,
|
||||
StudentOverlaps = GetStudentTeamOverlaps(teams),
|
||||
UnscheduledStudents = GetStudentsNotInTimSlot(teams, students)
|
||||
}
|
||||
).ToArray();
|
||||
|
||||
public static int GetStudentTeamOverlapCount(Team[][] timeSlots)
|
||||
{
|
||||
@@ -30,7 +37,6 @@ public class TeamSchedulerSolution(
|
||||
select Tuple.Create(gs.First(), gs.Key);
|
||||
}
|
||||
|
||||
|
||||
public static Student[] GetStudentsNotInTimSlot(Team[] timeSlot, Student[] students)
|
||||
{
|
||||
var studentsInTimeSlot = timeSlot.SelectMany(ts => ts.Students).Distinct();
|
||||
@@ -39,12 +45,11 @@ public class TeamSchedulerSolution(
|
||||
where studentsInTimeSlot.FirstOrDefault(e => e.Equals(allStudent)) == null
|
||||
select allStudent
|
||||
).ToArray();
|
||||
|
||||
}
|
||||
|
||||
public Team[] StudentUnassignedTeams(Student student)
|
||||
{
|
||||
var meetingTeams = TimeSlots.SelectMany(t => t);
|
||||
var meetingTeams = TimeSlots.SelectMany(t => t.Teams);
|
||||
return
|
||||
student.Teams.Where(e => !meetingTeams.Contains(e)).ToArray();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user