コード例 #1
0
ファイル: StudentTest.cs プロジェクト: Nottyy/TelerikAcademy
 public void TestNewStudentConstructorId()
 {
     string name = "Ivan Ivanov";
     int id = 12233;
     Student student = new Student(name, id);
     Assert.AreEqual(student.StudentId, id);
 }
コード例 #2
0
ファイル: StudentTest.cs プロジェクト: Nottyy/TelerikAcademy
 public void TestNewStudentConstructorOnMaxLimitId()
 {
     string name = "Ivan Ivanov";
     int id = 99999;
     Student student = new Student(name, id);
     Assert.AreEqual(id, student.StudentId);
 }
コード例 #3
0
ファイル: SchoolTest.cs プロジェクト: Nottyy/TelerikAcademy
 public void TestRemoveNotAddedStudent()
 {
     string name = "40 SOU";
     Student student = new Student("Ivan Ivanov", 12233);
     School school = new School(name);
     school.RemoveStudent(student);
 }
コード例 #4
0
ファイル: SchoolTest.cs プロジェクト: Nottyy/TelerikAcademy
 public void TestAddStudentId()
 {
     string name = "40 SOU";
     Student student = new Student("Ivan Ivanov", 12233);
     School school = new School(name);
     school.AddStudent(student);
     Assert.AreEqual(student.StudentId, school.StudentsList[0].StudentId);
 }
コード例 #5
0
ファイル: CourseTest.cs プロジェクト: Nottyy/TelerikAcademy
 public void TestJoinTheSameStudentId()
 {
     string name = "Crocheting";
     Student student = new Student("Ivan Ivanov", 12233);
     Course course = new Course(name);
     course.Join(student);
     course.Join(student);
 }
コード例 #6
0
ファイル: CourseTest.cs プロジェクト: Nottyy/TelerikAcademy
 public void TestJoinStudentId()
 {
     string name = "Crocheting";
     Student student = new Student("Ivan Ivanov", 12233);
     Course course = new Course(name);
     course.Join(student);
     Assert.AreEqual(student.StudentId, course.StudentsList[0].StudentId);
 }
コード例 #7
0
ファイル: CourseTest.cs プロジェクト: Nottyy/TelerikAcademy
 public void TestLeaveStudent()
 {
     string name = "Crocheting";
     Student student = new Student("Ivan Ivanov", 12233);
     Course course = new Course(name);
     course.Join(student);
     course.Leave(student);
     Assert.IsTrue(course.StudentsList.Count == 0);
 }
コード例 #8
0
ファイル: SchoolTest.cs プロジェクト: Nottyy/TelerikAcademy
 public void TestRemoveStudent()
 {
     string name = "40 SOU";
     Student student = new Student("Ivan Ivanov", 12233);
     School school = new School(name);
     school.AddStudent(student);
     school.RemoveStudent(student);
     Assert.IsTrue(school.StudentsList.Count == 0);
 }
コード例 #9
0
ファイル: School.cs プロジェクト: Nottyy/TelerikAcademy
 public void AddStudent(Student student)
 {
     if (this.IsStudentFound(student))
     {
         throw new ArgumentException(
             string.Format(
             "The student ID {0} already exists in the school's students list! Please choose a differnet student ID for student {1}",
             student.StudentId,
             student.Name)); 
     }
     else
     {
         this.StudentsList.Add(student);
     }
 }
コード例 #10
0
ファイル: School.cs プロジェクト: Nottyy/TelerikAcademy
 public void RemoveStudent(Student student)
 {
     if (this.IsStudentFound(student))
     {
         this.StudentsList.Remove(student);
     }
     else
     {
         throw new ArgumentException(
             string.Format(
             "Student not removed! The student ID {0} for student {1} dosn't exsit in the school's records!",
             student.StudentId,
             student.Name));            
     }
 }
コード例 #11
0
ファイル: Course.cs プロジェクト: Nottyy/TelerikAcademy
 public void Leave(Student student)
 {
     if (this.IsStudentFound(student))
     {
         this.StudentsList.Remove(student);
     }
     else
     {
         throw new ArgumentException(
             string.Format(
             "The student {0} {1} cannot leave the course because he/she hasn't joined this course!",
             student.StudentId,
             student.Name));               
     }
 }
コード例 #12
0
ファイル: Course.cs プロジェクト: Nottyy/TelerikAcademy
 public void Join(Student student)
 {
     if (this.IsStudentFound(student))
     {
         throw new ArgumentException(
             string.Format(
             "The student {0} {1} has already joined this course!", 
             student.StudentId, 
             student.Name));
     }
     else if (this.IsCourseFull())
     {
         throw new ArgumentOutOfRangeException("The course is full at the moment and doesn't accept new students!");
     }
     else
     {
         this.StudentsList.Add(student);
     }
 }
コード例 #13
0
ファイル: School.cs プロジェクト: Nottyy/TelerikAcademy
        private bool IsStudentFound(Student student)
        {
            for (int i = 0; i < this.StudentsList.Count; i++)
            {
                if (student.StudentId == this.StudentsList[i].StudentId)
                {
                    return true;
                }
            }

            return false;
        }
コード例 #14
0
ファイル: CourseTest.cs プロジェクト: Nottyy/TelerikAcademy
 public void TestLeaveNotJoinedStudent()
 {
     string name = "Crocheting";
     Student student = new Student("Ivan Ivanov", 12233);
     Course course = new Course(name);
     course.Leave(student);
 }
コード例 #15
0
ファイル: StudentTest.cs プロジェクト: Nottyy/TelerikAcademy
 public void TestNewStudentConstructorEmptyName()
 {
     string name = string.Empty;
     int id = 12233;
     Student student = new Student(name, id);
 }
コード例 #16
0
ファイル: StudentTest.cs プロジェクト: Nottyy/TelerikAcademy
 public void TestNewStudentConstructorPositiveLimitOfIntId()
 {
     string name = "Ivan Ivanov";
     int id = int.MaxValue;
     Student student = new Student(name, id);
 }
コード例 #17
0
ファイル: StudentTest.cs プロジェクト: Nottyy/TelerikAcademy
 public void TestNewStudentConstructorNegativeId()
 {
     string name = "Ivan Ivanov";
     int id = -1112;
     Student student = new Student(name, id);
 }
コード例 #18
0
ファイル: StudentTest.cs プロジェクト: Nottyy/TelerikAcademy
 public void TestNewStudentConstructorBelowMinLimitId()
 {
     string name = "Ivan Ivanov";
     int id = 9999;
     Student student = new Student(name, id);
 }
コード例 #19
0
ファイル: StudentTest.cs プロジェクト: Nottyy/TelerikAcademy
 public void TestStudentToString()
 {
     string name = "Ivan Ivanov";
     int id = 12233;
     Student student = new Student(name, id);
     string expected = "12233 Ivan Ivanov";
     string actual = student.ToString();
     Assert.AreEqual(expected, actual);
 }
コード例 #20
0
ファイル: StudentTest.cs プロジェクト: Nottyy/TelerikAcademy
 public void TestNewStudentConstructorZeroId()
 {
     string name = "Ivan Ivanov";
     int id = 0;
     Student student = new Student(name, id);
 }
コード例 #21
0
ファイル: CourseTest.cs プロジェクト: Nottyy/TelerikAcademy
 public void TestStudentToString()
 {
     string name = "Crocheting";
     Course course = new Course(name);
     Student student = new Student("Ivan Ivanov", 12233);
     course.Join(student);
     string expected = string.Format("Course: Crocheting{0}Subscribed students{0}12233 Ivan Ivanov{0}", Environment.NewLine);
     string actual = course.ToString();
     Assert.AreEqual(expected, actual);
 }
コード例 #22
0
ファイル: StudentTest.cs プロジェクト: Nottyy/TelerikAcademy
 public void TestNewStudentConstructorNullName()
 {
     string name = null;
     int id = 12233;
     Student student = new Student(name, id);
 }
コード例 #23
0
 public void AddStudent(Student student)
 {
     Students.Add(student);
 }
コード例 #24
0
        static void Main()
        {
            //Create a school
            School testSchool = new School("40 - SOU Loui Pastior");
            testSchool.Title = "40 - SOU Loui Pastior";

            //Add disciplines
            Discipline maths = new Discipline("Mathematics", 30, 30);
            Discipline bgLang = new Discipline("Bulgarian Language", 30, 30);
            Discipline enLang = new Discipline("English Language", 20, 20);

            //Add Students
            Student Ivanov = new Student("Ivan Ivanov", 1);
            Student Petrov = new Student("Ivan Petrov", 2);
            Student Ivanova = new Student("Petia Ivanova", 1);
            Student Ilieva = new Student("Kalina Ilieva", 2);
            Student Kostov = new Student("Jordan Kostov", 3);
            Student Kirchev = new Student("Pencho Kirchev", 4);

            //Add Teachers
            Teacher Petrova = new Teacher("Tania Petrova", new List<Discipline> {maths, enLang });
            Teacher Georgiev = new Teacher("Georgi Georgiev", new List<Discipline> { bgLang, enLang });

            //Add some comments
            Georgiev.AddComment("Only morning classes");
            Georgiev.AddComment("Free Wednesdays");
            Ivanova.AddComment("Not present every second Tuesday due to medical issues");

           
            //Add 2 classes
            SchoolClass firstA = new SchoolClass("I A", new List<Student>() , new List<Teacher> ());
            firstA.AddStudent(Ivanov);
            firstA.AddStudent(Petrov);
            firstA.AddStudent(Kostov);
            firstA.AddStudent(Kirchev);
            firstA.AddTeacher(Petrova);

            testSchool.AddSchoolClass( firstA);

           SchoolClass firstB = new SchoolClass("I B", new List<Student> (), new List<Teacher>());
           firstB.AddStudent(Ivanova);
           firstB.AddStudent(Ilieva);
           firstB.AddTeacher(Petrova);
           firstB.AddTeacher(Georgiev);
           testSchool.AddSchoolClass(firstB);

            //Print on the console
            Console.WriteLine("Information about a discipline:");
            Console.WriteLine(maths);
            Console.WriteLine();
            Console.WriteLine("Information about a teacher:");
            Console.WriteLine(Georgiev);
            Console.WriteLine();
            Console.WriteLine("Information about a student:");
            Console.WriteLine(Ilieva);
            Console.WriteLine();
            Console.WriteLine("Information about a school class:");
            Console.WriteLine(firstA);
            Console.WriteLine();
            Console.WriteLine("Information about a school:");
            Console.WriteLine(testSchool);
            
        }