using System.Text.RegularExpressions; using Zurnal.RemaDateBase.DateDao; public class GroupAttendanceService { private List attendances; public void DisplayGroupInfo() { Console.WriteLine( $"Группа: {GroupName}"); Console.WriteLine( $"Количество студентов: {Count()}"); var totalClasses = new AttendanceCounter(attendances).CountAttendances(UserGuid); Console.WriteLine($"Количество проведенных занятий: {totalClasses}"); var overallAttendancePercentage = CalculateAttendancePercentage(); Console.WriteLine($"Общий процент посещаемости: {overallAttendancePercentage:F2}%"); Console.WriteLine("Список студентов:"); foreach (var user in Group.Users) { var attendanceInfo = GetAttendanceInfo(user); Console.WriteLine($"{user.FIO}: Посещенные занятия: {attendanceInfo.AttendedClasses}, Пропущенные занятия: {attendanceInfo.MissedClasses}, Процент посещаемости: {attendanceInfo.AttendancePercentage:F2}%"); } } public class AttendanceCounter { private List _attendances; public AttendanceCounter(List attendances) { _attendances = attendances; } public int CountAttendances(Guid userGuid) { return _attendances.Count(a => a.UserGuid == userGuid && a.IsAttendensy); } internal object CountAttendances(object userGuid) { throw new NotImplementedException(); } } public static double CalculateAttendancePercentage(List attendanceRecords, Guid userGuid) { var userRecords = attendanceRecords.Where(record => record.UserGuid == userGuid).ToList(); if (userRecords.Count == 0) return 0; int totalLessons = userRecords.Count; int attendedLessons = userRecords.Count(record => record.IsAttendensy); return (double)attendedLessons / totalLessons * 100; } private (int AttendedClasses, int MissedClasses, double AttendancePercentage) GetAttendanceInfo(UserDao user) { private List attendanceRecords; public AttendanceService(List records) { attendanceRecords = records; } public List GetAttendanceByUser(Guid userGuid) { return attendanceRecords.Where(record => record.UserGuid == userGuid).ToList(); } public Dictionary GetAttendanceSummary(Guid userGuid) { var userAttendance = attendanceRecords.Where(record => record.UserGuid == userGuid); var summary = new Dictionary(); foreach (var record in userAttendance) { if (summary.ContainsKey(record.Date)) { summary[record.Date]++; } else { summary[record.Date] = 1; } } return summary; } } }