Пример #1
0
    //题4:为course类实现一个CancelSection方法
    public void CancelSection(string day, string time, string room, int capacity)
    {
        Section s = new Section(OfferedAsSection.Count - 1,
                                day, time, this, room, capacity);

        OfferedAsSection.Remove(s);
    }
Пример #2
0
    //题4
    //实现一个CancelSection方法
    public void CancelSection(Section s)
    {
        //课程被移除
        OfferedAsSection.Remove(s);
        //选课项被移除
        s.OfferedIn.SectionsOffered.Remove(s.RepresentedCourse.CourseNumber +
                                           " - " + s.SectionNumber);

        Console.WriteLine("课程已经被移出选课表!");
    }
Пример #3
0
    //练习4
    public void CancelSection(Section s)
    {
        //该课程从选课列表中移除
        OfferedAsSection.Remove(s);
        //选课项从选课列表中移除
        s.OfferedIn.SectionsOffered.Remove(s.RepresentedCourse.CourseNumber +
                                           " - " + s.SectionNumber);

        Console.WriteLine("该课程已成功移出选课列表!");
    }
Пример #4
0
    //*****************************************************************************
    //
    public Section ScheduleSection(int secNumber, string day, string time, string room,
                                   int capacity)
    {
        // Create a new Section  ...
        Section s = new Section(secNumber, day, time, this, room, capacity);

        // ... and then remember it!
        OfferedAsSection.Add(s);

        return(s);
    }
Пример #5
0
    //******************************************************************
    //
    public Section ScheduleSection(string day, string time, string room,
                                   int capacity)
    {
        // Create a new Section (note the creative way in
        // which we are assigning a section number) ...
        Section s = new Section(OfferedAsSection.Count + 1, day, time, this, room, capacity);

        // ... and then add it to the List
        OfferedAsSection.Add(s);

        return(s);
    }
Пример #6
0
    //第四题
    public void CancelSection(Section sec)
    {
        int index = -1;

        if (OfferedAsSection.Contains(sec))
        {
            for (int i = 0; i < OfferedAsSection.Count; i++)
            {
                if (OfferedAsSection[i] == sec)
                {
                    //根据选课取得索引
                    index = i;
                    break;
                }
            }
            OfferedAsSection.RemoveAt(index);
            Console.WriteLine(sec + "这门课程已经移除!");
        }

        else
        {
            Console.WriteLine(sec + "这门课程不存在!");
        }
    }
Пример #7
0
 //练习14.3:创建CancelSection方法
 public void CancelSection(Section s)
 {
     OfferedAsSection.Remove(s);
 }