﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OOPPI
{
    class SchoolClass:ICommentalbe
    {
        private List<string> comments;
        public void AddComment(string comment)
        {
            comments.Add(comment);
        }
        public IReadOnlyList<string> GetComments()
        {
            return comments.AsReadOnly();
        }
        public SchoolClass(string name)
        {
            this.comments = new List<string>();
            classTeachers=new List<Teacher>();
            classMembers=new List<Student>();
        }
       
        internal string classID;
        private List<Student> classMembers;
        public void AddStudent(string FirstName, string FamilyName)
        {
            byte studentNumber = 1;
            for (int i = 0; i < classMembers.Count; i++)
            {
                if (studentNumber != classMembers[i].studentClassNumber)
                {
                    break;
                }
            }
            if (studentNumber == 255)
            {
                Console.WriteLine("Class full!!!. Can't have more than 255 students in one class");
            }
            else
            {
                Student StudentToAdd = new Student(FirstName, FamilyName);
                StudentToAdd.studentClassNumber = studentNumber;
                classMembers.Insert(studentNumber-1, StudentToAdd);
            }
        }
        public bool AddCommentForStudent(string comment, byte number)
        {
            for (int i = 0; i < classMembers.Count; i++)
            {
                if (classMembers[i].StudentClassNumber == number)
                {
                    classMembers[i].AddComment(comment);
                    return true;
                }
            }
            return false;
        }
        public bool RemoveStudentNumber(byte number)
        {
            for (int i = 0; i < classMembers.Count; i++)
            {
                if (classMembers[i].StudentClassNumber == number)
                {
                    classMembers.RemoveAt(i);
                    return true;
                }
            }
            return false;
        }
        public IReadOnlyList<Student> ClassMembers
        {
            get { return classMembers.AsReadOnly(); }

        }
        private List<Teacher> classTeachers;
        public void AddTeacher(Teacher TeacherToAdd)
        {
            classTeachers.Add(TeacherToAdd);
        }
        public bool RemoveTeacher(string FirstName, string LastName)
        {
            for (int i = 0; i < classTeachers.Count; i++)
            {
                if (classTeachers[i].FirstName == FirstName && classTeachers[i].LastName == LastName)
                {
                    classTeachers.RemoveAt(i);
                    return true;
                }
            }
            return false;
        }


        internal IReadOnlyList<Teacher> ClassTeachers
        {
            get { return classTeachers.AsReadOnly(); }
        }



    }
}
