コード例 #1
0
        //public int sectionid;

        public section getSectionBypreference(int prefernceNumber)
        {
            return(preferences.ReurnSectionByindex(prefernceNumber));
        }
コード例 #2
0
ファイル: Form2.cs プロジェクト: uelfar/Classification
        private void Form2_Load(object sender, EventArgs e)
        {
            secList.AddSection(new section(1, "1", 3));
            secList.AddSection(new section(2, "2", 2));
            secList.AddSection(new section(3, "3", 2));
            secList.AddSection(new section(4, "4", 3));
            secList.AddSection(new section(5, "5", 1));



            //student 1
            student s1 = new student();

            s1.id   = 1;
            s1.name = "1";
            s1.preferences.AddSection(secList.RestSectionByID(1));
            s1.preferences.AddSection(secList.RestSectionByID(2));
            s1.preferences.AddSection(secList.RestSectionByID(3));
            s1.preferences.AddSection(secList.RestSectionByID(4));
            s1.preferences.AddSection(secList.RestSectionByID(5));



            s1.sectionGrade.Add(secList.RestSectionByID(1), 100);
            s1.sectionGrade.Add(secList.RestSectionByID(2), 200);
            s1.sectionGrade.Add(secList.RestSectionByID(3), 2000);
            s1.sectionGrade.Add(secList.RestSectionByID(4), 100);
            s1.sectionGrade.Add(secList.RestSectionByID(5), 10);

            tmpSection.stdlist.addstudent(s1);


            //student 2
            s1      = new student();
            s1.id   = 2;
            s1.name = "2";
            s1.preferences.AddSection(secList.RestSectionByID(5));
            s1.preferences.AddSection(secList.RestSectionByID(3));
            s1.preferences.AddSection(secList.RestSectionByID(2));
            s1.preferences.AddSection(secList.RestSectionByID(4));
            s1.preferences.AddSection(secList.RestSectionByID(1));

            s1.sectionGrade.Add(secList.RestSectionByID(1), 900);
            s1.sectionGrade.Add(secList.RestSectionByID(2), 300);
            s1.sectionGrade.Add(secList.RestSectionByID(3), 50);
            s1.sectionGrade.Add(secList.RestSectionByID(4), 300);
            s1.sectionGrade.Add(secList.RestSectionByID(5), 50);

            tmpSection.stdlist.addstudent(s1);



            //student 3
            s1      = new student();
            s1.id   = 3;
            s1.name = "3";
            s1.preferences.AddSection(secList.RestSectionByID(5));
            s1.preferences.AddSection(secList.RestSectionByID(2));
            s1.preferences.AddSection(secList.RestSectionByID(1));
            s1.preferences.AddSection(secList.RestSectionByID(4));
            s1.preferences.AddSection(secList.RestSectionByID(3));


            s1.sectionGrade.Add(secList.RestSectionByID(1), 800);
            s1.sectionGrade.Add(secList.RestSectionByID(2), 400);
            s1.sectionGrade.Add(secList.RestSectionByID(3), 60);
            s1.sectionGrade.Add(secList.RestSectionByID(4), 200);
            s1.sectionGrade.Add(secList.RestSectionByID(5), 90);



            tmpSection.stdlist.addstudent(s1);



            //student 4
            s1      = new student();
            s1.id   = 4;
            s1.name = "4";
            s1.preferences.AddSection(secList.RestSectionByID(2));
            s1.preferences.AddSection(secList.RestSectionByID(5));
            s1.preferences.AddSection(secList.RestSectionByID(3));
            s1.preferences.AddSection(secList.RestSectionByID(4));
            s1.preferences.AddSection(secList.RestSectionByID(1));

            s1.sectionGrade.Add(secList.RestSectionByID(1), 1000);
            s1.sectionGrade.Add(secList.RestSectionByID(2), 20);
            s1.sectionGrade.Add(secList.RestSectionByID(3), 70);
            s1.sectionGrade.Add(secList.RestSectionByID(4), 220);
            s1.sectionGrade.Add(secList.RestSectionByID(5), 70);

            tmpSection.stdlist.addstudent(s1);



            //student 5
            s1      = new student();
            s1.id   = 5;
            s1.name = "5";
            s1.preferences.AddSection(secList.RestSectionByID(1));
            s1.preferences.AddSection(secList.RestSectionByID(2));
            s1.preferences.AddSection(secList.RestSectionByID(3));
            s1.preferences.AddSection(secList.RestSectionByID(4));
            s1.preferences.AddSection(secList.RestSectionByID(5));

            s1.sectionGrade.Add(secList.RestSectionByID(1), 2000);
            s1.sectionGrade.Add(secList.RestSectionByID(2), 50);
            s1.sectionGrade.Add(secList.RestSectionByID(3), 75);
            s1.sectionGrade.Add(secList.RestSectionByID(4), 250);
            s1.sectionGrade.Add(secList.RestSectionByID(5), 110);

            tmpSection.stdlist.addstudent(s1);



            //student 6
            s1      = new student();
            s1.id   = 6;
            s1.name = "6";
            s1.preferences.AddSection(secList.RestSectionByID(2));
            s1.preferences.AddSection(secList.RestSectionByID(5));
            s1.preferences.AddSection(secList.RestSectionByID(1));
            s1.preferences.AddSection(secList.RestSectionByID(3));
            s1.preferences.AddSection(secList.RestSectionByID(4));

            s1.sectionGrade.Add(secList.RestSectionByID(1), 50);
            s1.sectionGrade.Add(secList.RestSectionByID(2), 90);
            s1.sectionGrade.Add(secList.RestSectionByID(3), 72);
            s1.sectionGrade.Add(secList.RestSectionByID(4), 30);
            s1.sectionGrade.Add(secList.RestSectionByID(5), 120);

            tmpSection.stdlist.addstudent(s1);



            //student 7
            s1      = new student();
            s1.id   = 7;
            s1.name = "7";
            s1.preferences.AddSection(secList.RestSectionByID(3));
            s1.preferences.AddSection(secList.RestSectionByID(2));
            s1.preferences.AddSection(secList.RestSectionByID(1));
            s1.preferences.AddSection(secList.RestSectionByID(4));
            s1.preferences.AddSection(secList.RestSectionByID(5));

            s1.sectionGrade.Add(secList.RestSectionByID(1), 90);
            s1.sectionGrade.Add(secList.RestSectionByID(2), 70);
            s1.sectionGrade.Add(secList.RestSectionByID(3), 83);
            s1.sectionGrade.Add(secList.RestSectionByID(4), 20);
            s1.sectionGrade.Add(secList.RestSectionByID(5), 130);

            tmpSection.stdlist.addstudent(s1);


            //student 8
            s1      = new student();
            s1.id   = 8;
            s1.name = "8";
            s1.preferences.AddSection(secList.RestSectionByID(4));
            s1.preferences.AddSection(secList.RestSectionByID(5));
            s1.preferences.AddSection(secList.RestSectionByID(3));
            s1.preferences.AddSection(secList.RestSectionByID(1));
            s1.preferences.AddSection(secList.RestSectionByID(2));

            s1.sectionGrade.Add(secList.RestSectionByID(1), 70);
            s1.sectionGrade.Add(secList.RestSectionByID(2), 70);
            s1.sectionGrade.Add(secList.RestSectionByID(3), 54);
            s1.sectionGrade.Add(secList.RestSectionByID(4), 10);
            s1.sectionGrade.Add(secList.RestSectionByID(5), 200);

            tmpSection.stdlist.addstudent(s1);


            //student 9
            s1      = new student();
            s1.id   = 9;
            s1.name = "9";
            s1.preferences.AddSection(secList.RestSectionByID(2));
            s1.preferences.AddSection(secList.RestSectionByID(1));
            s1.preferences.AddSection(secList.RestSectionByID(4));
            s1.preferences.AddSection(secList.RestSectionByID(5));
            s1.preferences.AddSection(secList.RestSectionByID(3));

            s1.sectionGrade.Add(secList.RestSectionByID(1), 10);
            s1.sectionGrade.Add(secList.RestSectionByID(2), 700);
            s1.sectionGrade.Add(secList.RestSectionByID(3), 50);
            s1.sectionGrade.Add(secList.RestSectionByID(4), 900);
            s1.sectionGrade.Add(secList.RestSectionByID(5), 220);

            tmpSection.stdlist.addstudent(s1);


            //student 10
            s1      = new student();
            s1.id   = 10;
            s1.name = "10";
            s1.preferences.AddSection(secList.RestSectionByID(3));
            s1.preferences.AddSection(secList.RestSectionByID(5));
            s1.preferences.AddSection(secList.RestSectionByID(1));
            s1.preferences.AddSection(secList.RestSectionByID(2));
            s1.preferences.AddSection(secList.RestSectionByID(4));

            s1.sectionGrade.Add(secList.RestSectionByID(1), 30);
            s1.sectionGrade.Add(secList.RestSectionByID(2), 900);
            s1.sectionGrade.Add(secList.RestSectionByID(3), 60);
            s1.sectionGrade.Add(secList.RestSectionByID(4), 1000);
            s1.sectionGrade.Add(secList.RestSectionByID(5), 230);

            tmpSection.stdlist.addstudent(s1);



            //student 11
            s1      = new student();
            s1.id   = 11;
            s1.name = "11";
            s1.preferences.AddSection(secList.RestSectionByID(4));
            s1.preferences.AddSection(secList.RestSectionByID(5));
            s1.preferences.AddSection(secList.RestSectionByID(3));
            s1.preferences.AddSection(secList.RestSectionByID(2));
            s1.preferences.AddSection(secList.RestSectionByID(1));

            s1.sectionGrade.Add(secList.RestSectionByID(1), 200);
            s1.sectionGrade.Add(secList.RestSectionByID(2), 1000);
            s1.sectionGrade.Add(secList.RestSectionByID(3), 100);
            s1.sectionGrade.Add(secList.RestSectionByID(4), 2000);
            s1.sectionGrade.Add(secList.RestSectionByID(5), 250);

            tmpSection.stdlist.addstudent(s1);


            for (int index = 0; index < secList.secList.Count; index++)
            {
                tmpSection.id = secList.ReurnSectionByindex(index).id;
                tmpSection.SortWithGrade();
                for (int i = 0; i < secList.ReurnSectionByindex(index).sectionSize; i++)
                {
                    secList.ReurnSectionByindex(index).stdlist.addstudent(tmpSection.stdlist.GetStudentyIndex(i));
                }

                for (int i = 0; i < secList.ReurnSectionByindex(index).sectionSize; i++)
                {
                    tmpSection.stdlist.removeStudent(secList.ReurnSectionByindex(index).stdlist.GetStudentyIndex(i));
                }
            }


            /*
             * section HisCurrentSection = secList.ReurnSectionByindex(0);
             * student currentStudent = HisCurrentSection.stdlist.GetStudentyIndex(0);
             * section SeekedSection = secList.ReurnSectionByindex(1);
             * student TargetStudent = SeekedSection.stdlist.GetStudentyIndex(0);
             *
             *
             *  SwapStudents(secList, currentStudent, 0, TargetStudent, 1);
             */



            while (RelocateStudents())
            {
            }


            int x = 1;



            dataGridView1.Rows.Add();
            dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[0].Value = "Showing results";
            for (int i = 0; i < secList.secList.Count; i++)
            {
                dataGridView1.Rows.Add();
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[0].Value = "in section : ";
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[1].Value = secList.secList[i].name;
                string sts = "students : ";
                for (int i2 = 0; i2 < secList.secList[i].stdlist.GetCount(); i2++)
                {
                    sts = sts + secList.secList[i].stdlist.GetStudentyIndex(i2).name + ",";
                }
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[2].Value = sts;
            }
        }