namespace Domain.Entities;

public class Subject
{
    public const int CreditsPerSubject = 3;

    public int Id { get; private set; }
    public string Name { get; private set; } = string.Empty;
    public int Credits { get; private set; } = CreditsPerSubject;
    public int ProfessorId { get; private set; }
    public Professor Professor { get; private set; } = null!;

    private readonly List<Enrollment> _enrollments = [];
    public IReadOnlyCollection<Enrollment> Enrollments => _enrollments.AsReadOnly();

    private Subject() { }

    public Subject(string name, int professorId)
    {
        if (string.IsNullOrWhiteSpace(name))
            throw new ArgumentException("Subject name is required", nameof(name));

        Name = name;
        Credits = CreditsPerSubject;
        ProfessorId = professorId;
    }
}
