UniteSchools() public static method

public static UniteSchools ( List schools, List schoolNumbers ) : void
schools List
schoolNumbers List
return void
Ejemplo n.º 1
0
    public static void Main(string[] args)
    {
        var pupils  = new List <Pupil>();
        var schools = new List <School>();

        using (var sr = new StreamReader("schools.txt"))
        {
            int pupilsNumber = int.Parse(sr.ReadLine());
            while (pupilsNumber-- > 0)
            {
                pupils.Add(GetPupil(sr.ReadLine().Split()));
            }

            int schoolsNumber = int.Parse(sr.ReadLine());
            while (schoolsNumber-- > 0)
            {
                schools.Add(GetSchool(sr.ReadLine().Split("; "), pupils));
            }

            int commandsNumber = int.Parse(sr.ReadLine());
            while (commandsNumber-- > 0)
            {
                string[] command = sr.ReadLine().Split();
                switch (command[0])
                {
                case "mv":
                    SchoolManager.TransferPupil(pupils, schools, pupilId: int.Parse(command[1]), newSchoolNumber: command[2]);
                    break;

                case "union":
                    var schoolsNumbers = command.Skip(1).ToList();
                    SchoolManager.UniteSchools(schools, schoolsNumbers);
                    break;

                case "close":
                    SchoolManager.CloseSchool(schools, schoolNumber: command[1], newSchoolNumber: command[2]);
                    break;
                }
            }
        }

        using (var sw = new StreamWriter("schools_after_reform.txt"))
        {
            schools.ForEach(sw.WriteLine);
        }
    }