当前位置: 首页>>代码示例>>C#>>正文


C# Course.AddStudentToCourse方法代码示例

本文整理汇总了C#中Course.AddStudentToCourse方法的典型用法代码示例。如果您正苦于以下问题:C# Course.AddStudentToCourse方法的具体用法?C# Course.AddStudentToCourse怎么用?C# Course.AddStudentToCourse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Course的用法示例。


在下文中一共展示了Course.AddStudentToCourse方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IfTryToAddExistingStudentToCourseThrowInvalidOperationException

        public void IfTryToAddExistingStudentToCourseThrowInvalidOperationException()
        {
            string courseName = "Hight Quality Code";
            string studentName = "Ivan Ivanov";
            int studentId = 10000;

            Course course = new Course(courseName);
            Student student = new Student(studentName, studentId);

            course.AddStudentToCourse(student);
            course.AddStudentToCourse(student);
        }
开发者ID:tzigy,项目名称:TelerikAcademy,代码行数:12,代码来源:CourseTest.cs

示例2: RemoveStudentFromCourse_ShouldThrowException_WhenAddMoreThanThirtyStudents

 public void RemoveStudentFromCourse_ShouldThrowException_WhenAddMoreThanThirtyStudents()
 {
     // Arrange and Act
     var peshoStudent = new Student("Pesho", 54342);
     var course = new Course();
     for (int i = 0; i <= 33; i++)
     {
         course.AddStudentToCourse(peshoStudent);
     }
 }
开发者ID:todor-enikov,项目名称:TelerikAcademy,代码行数:10,代码来源:CourseClassTesting.cs

示例3: AddStudentToCourse_ShouldAddStudentToCourseCorrectly

        public void AddStudentToCourse_ShouldAddStudentToCourseCorrectly()
        {
            // Arrange
            var peshoStudent = new Student("Pesho",54342);
            var course = new Course();

            // Act
            course.AddStudentToCourse(peshoStudent);

            // Assert
            Assert.AreEqual(1, course.Students.Count);
        }
开发者ID:todor-enikov,项目名称:TelerikAcademy,代码行数:12,代码来源:CourseClassTesting.cs

示例4: IfStudentsListIsFullThrowArgumentOutOfRangeException

        public void IfStudentsListIsFullThrowArgumentOutOfRangeException()
        {
            string courseName = "Hight Quality Code";
            string studentName = "Ivan Ivanov";
            int studentId = 10000;

            Course course = new Course(courseName);

            for (int i = 0; i <= 30; i++)
            {
                Student student = new Student(studentName + i, studentId + i);
                course.AddStudentToCourse(student);
            }
        }
开发者ID:tzigy,项目名称:TelerikAcademy,代码行数:14,代码来源:CourseTest.cs

示例5: Main

        static void Main(string[] args)
        {
            Student student1 = new Student();
            student1.StudentFirstName = "John";
            student1.StudentLastName = "Lennon";
            student1.StudentBirthDate = DateTime.Parse("19/02/1945");
            student1.StudentCity = "Liverpool";
            student1.StudentCountry = "United Kingdom";
            student1.AddGrades(10, 9.8, 8.7, 9, 8);

            Student student2 = new Student();
            student2.StudentFirstName = "Paul";
            student2.StudentLastName = "Mcartney";
            student2.StudentBirthDate = DateTime.Parse("10/06/1951");
            student2.StudentCity = "Liverpool";
            student2.StudentCountry = "United Kingdom";
            student2.AddGrades(8, 10, 9.9, 10, 9.5);

            Student student3 = new Student();
            student3.StudentFirstName = "George";
            student3.StudentLastName = "Harrison";
            student3.StudentBirthDate = DateTime.Parse("22/09/1956");
            student3.StudentCity = "Manchester";
            student3.StudentCountry = "United Kingdom";
            student3.AddGrades(9, 10, 10, 10, 8.5);

            Course programmingWithC = new Course();
            programmingWithC.Name = "Programming with C #";
            programmingWithC.AddStudentToCourse(student1);
            programmingWithC.AddStudentToCourse(student2);
            programmingWithC.AddStudentToCourse(student3);

            Console.WriteLine("The {0} course contains {1} student(s)", programmingWithC.Name, programmingWithC.StudentCourseCount.ToString());
            Console.WriteLine("---------------------------------");

            Console.WriteLine("Students in {0} course:", programmingWithC.Name);
            programmingWithC.ListStudents();
            Console.WriteLine("---------------------------------");
            Console.WriteLine();
            Console.WriteLine();

            Console.WriteLine("Press any key to quit");
            Console.ReadKey();
        }
开发者ID:alban316,项目名称:edxCSharp,代码行数:44,代码来源:Program.cs

示例6: IfTryToAddNullStudentToCourseThrowArgumentNullException

        public void IfTryToAddNullStudentToCourseThrowArgumentNullException()
        {
            string name = "Hight Quality Code";
            Student student = null;

            Course course = new Course(name);
            course.AddStudentToCourse(student);
        }
开发者ID:tzigy,项目名称:TelerikAcademy,代码行数:8,代码来源:CourseTest.cs

示例7: StudentShouldBeRemovedInCourseList

        public void StudentShouldBeRemovedInCourseList()
        {
            string courseName = "Hight Quality Code";
            string studentName = "Ivan Ivanov";
            int studentId = 10000;

            Course course = new Course(courseName);
            Student student = new Student(studentName, studentId);
            course.AddStudentToCourse(student);
            course.RemoveStudentFromCourse(student);

            Assert.AreEqual(0, course.Students.Count);
        }
开发者ID:tzigy,项目名称:TelerikAcademy,代码行数:13,代码来源:CourseTest.cs

示例8: StudentShouldBeAddetInCourseList

        public void StudentShouldBeAddetInCourseList()
        {
            string courseName = "Hight Quality Code";
            string studentName = "Ivan Ivanov";
            int studentId = 10000;

            Course course = new Course(courseName);
            Student student = new Student(studentName, studentId);
            course.AddStudentToCourse(student);

            Assert.AreSame(student, course.Students.First());
        }
开发者ID:tzigy,项目名称:TelerikAcademy,代码行数:12,代码来源:CourseTest.cs


注:本文中的Course.AddStudentToCourse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。