Ejemplo n.º 1
0
        public void RemoveStudent(Student s)
        {
            if (s == this.students[this.StudentCount - 1])
            {
                this.students[this.StudentCount--] = null;
                s.RemoveCourse(this);
                return;
            }
            bool notFound = true;

            for (int i = 0; i < this.StudentCount - 1; ++i)
            {
                if (s == this.students[i] && notFound)
                {
                    this.students[i] = null;
                    this.StudentCount--;
                    s.RemoveCourse(this);
                    notFound = false;
                }
                if (!notFound)
                {
                    this.students[i] = this.students[i + 1];
                }
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var s0 = new Student("Naimul 0", "154", 3.50F);
            var s1 = new Student("Naimul 1", "19", 3.61F);
            var s2 = new Student("naimul 10", "22", 3.62F);



            var c0 = new Course("001", "Web tech");
            var c1 = new Course("002", "DLC");
            var c2 = new Course("003", "OOP 2");



            c0.AddStudent(s1, s2);

            c0.PrintStudent();

            c0.RemoveStudent(s0);

            Console.WriteLine("******After student removed*****");

            s0.PrintCourse();
            c0.PrintStudent();

            Console.WriteLine();

            s2.AddCourse(c0, c1, c2);
            s2.PrintCourse();

            s2.RemoveCourse(c1);
            Console.WriteLine("##### After Remove  A Course#####");
            s2.PrintCourse();
            c1.PrintStudent();
        }