本文整理汇总了C#中Course.CancelSection方法的典型用法代码示例。如果您正苦于以下问题:C# Course.CancelSection方法的具体用法?C# Course.CancelSection怎么用?C# Course.CancelSection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Course
的用法示例。
在下文中一共展示了Course.CancelSection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Professor p1, p2, p3;
Student s1, s2, s3;
Course c1, c2, c3, c4, c5;
Section sec1, sec2, sec3, sec4, sec5, sec6, sec7;
// 创建多个对象(可能调用不同的构造函数)
// 通常从数据库或文件中读取数据加载对象到内存中
// -----------
// Professors.
// -----------
p1 = new Professor("Jacquie Barker", "123-45-6789",
"Adjunct Professor", "Information Technology");
p2 = new Professor("John Carson", "567-81-2345",
"Full Professor", "Chemistry");
p3 = new Professor("Jackie Chan", "987-65-4321",
"Full Professor", "Physical Education");
// Add these to the appropriate List.
faculty = new List<Professor>();//列表需要先实例化再使用
faculty.Add(p1);
faculty.Add(p2);
faculty.Add(p3);
// ---------
// Students.
// ---------
s1 = new Student("Zachary Palmer", "111-11-1111", "Math", "M.S.");
s2 = new Student("Gerson Lopez", "222-22-2222",
"Information Technology", "Ph. D.");
s3 = new Student("Mannat Durgapal", "333-33-3333", "Physics", "B.S.");
// Add these to the appropriate List.
studentBody = new List<Student>();
studentBody.Add(s1);
studentBody.Add(s2);
studentBody.Add(s3);
// --------
// Courses.
// --------
c1 = new Course("CMP101", "Beginning Computer Technology", 3.0);
c2 = new Course("OBJ101", "Object Methods for Software Development", 3.0);
c3 = new Course("CMP283", "Higher Level Languages (C#)", 3.0);
c4 = new Course("CMP999", "Living Brain Computers", 3.0);
c5 = new Course("ART101", "Beginning Basketweaving", 3.0);
// Add these to the appropriate List.
courseCatalog = new List<Course>();
courseCatalog.Add(c1);
courseCatalog.Add(c2);
courseCatalog.Add(c3);
courseCatalog.Add(c4);
courseCatalog.Add(c5);
// 建立课程间的先修关系 (c1 => c2 => c3 => c4).
c2.AddPrerequisite(c1);
c3.AddPrerequisite(c2);
c4.AddPrerequisite(c3);
c2.AddPrerequisite(c2);//测试是否可以把它自己设为先修课程。题2
// ---------
// Sections.
// ---------
// 通过调用Course对象的ScheduleSection方法生成一个Section对象,相当于给某门课建立一个排课
//Schedule sections of each Course by calling the
// scheduleSection method of Course (which internally
// invokes the Section constructor).
sec1 = c1.ScheduleSection("M", "8:10 - 10:00 PM", "GOVT101", 30);
sec2 = c1.ScheduleSection("W", "6:10 - 8:00 PM", "GOVT202", 30);
sec3 = c2.ScheduleSection("Th", "4:10 - 6:00 PM", "GOVT105", 25);
sec4 = c2.ScheduleSection("Tu", "6:10 - 8:00 PM", "SCI330", 25);
sec5 = c3.ScheduleSection("M", "6:10 - 8:00 PM", "GOVT101", 20);
sec6 = c4.ScheduleSection("Th", "4:10 - 6:00 PM", "SCI241", 15);
sec7 = c5.ScheduleSection("F", "4:10 - 6:00 PM", "ARTS25", 40);
//将Section加入到选课列表中
// Add these to the Schedule of Classes.
scheduleOfClasses.AddSection(sec1);
scheduleOfClasses.AddSection(sec2);
scheduleOfClasses.AddSection(sec3);
scheduleOfClasses.AddSection(sec4);
scheduleOfClasses.AddSection(sec5);
scheduleOfClasses.AddSection(sec6);
scheduleOfClasses.AddSection(sec7);
c1.CancelSection(sec1);//测试第四题,删除课程
//.........这里部分代码省略.........