コード例 #1
0
ファイル: TestExec.cs プロジェクト: tormibg/SoftUni-1
        public static void Main()
        {
            // Create & loads Teacher & Disciplines
            Teacher teacherOne = new Teacher("Goshko", "Goshkov");
            Discipline disciplineOne = new Discipline("Mathematica", 4, 10);
            Discipline disciplineTwo = new Discipline("Phisics", 10, 6);
            teacherOne.AddDiscipline(disciplineOne);
            teacherOne.AddDiscipline(disciplineTwo);

            // Create & loads students
            Student studentOne = new Student("Petarcho", "Petarchov", 1);
            Student studentTwo = new Student("Yordancho", "Yordanov", 2);
            Student studentThree = new Student("Zuyo", "Zuev", 1);
            Student studentFour = new Student("Suzi", "Suzankovichkova", 2);

            // Create & loads class with students and teachers
            Class classOne = new Class("Class One");
            try
            {
                classOne.AddStudent(studentOne);
                classOne.AddStudent(studentTwo);
                classOne.AddTeacher(teacherOne);
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(e.Message);
            }

            Teacher teacherTwo = new Teacher("Petunia", "Petunkova", new Discipline("Rocket Science", 1000, 6000));
            Class classTwo = new Class("Class Two");
            try
            {
                classTwo.AddStudent(studentThree);
                classTwo.AddStudent(studentFour);
                classTwo.AddTeacher(teacherOne);
                classTwo.AddTeacher(teacherTwo);
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(e.Message);
            }

            // Create & loads school and add class
            School school = new School();
            school.AddClass(classOne);
            school.AddClass(classTwo);
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("School details:");
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(school.ToString());
        }
コード例 #2
0
ファイル: Teacher.cs プロジェクト: tormibg/SoftUni-1
 /// <summary>
 /// Remove discipline from the list of disciplines lead by the teacher.
 /// If discipline is not available, no exception is thrown as well as no change is introduced.
 /// </summary>
 /// <param name="discipline">Discipline instance to be removed.</param>
 public void Remove(Discipline discipline)
 {
     if (discipline != null)
     {
         if (this.Disciplines.Contains(discipline))
         {
             this.disciplines.Remove(discipline);
         }
     }
     else
     {
         throw new ArgumentNullException("discipline", "Discipline instance can not be null!");
     }
 }
コード例 #3
0
ファイル: Teacher.cs プロジェクト: tormibg/SoftUni-1
 /// <summary>
 /// Add discipline to the list of disciplines lead by the teacher.
 /// If discipline already exist in the list, no changes are applied.
 /// </summary>
 /// <param name="discipline">Discipline instance to be added to the list.</param>
 public void AddDiscipline(Discipline discipline)
 {
     if (discipline != null)
     {
         if (!this.Disciplines.Contains(discipline))
         {
             this.disciplines.Add(discipline);
         }
     }
     else
     {
         throw new ArgumentNullException("discipline", "You can add null discipline reference to list!");
     }
 }
コード例 #4
0
ファイル: Teacher.cs プロジェクト: tormibg/SoftUni-1
 /// <summary>
 /// Instantiate an object of type Teacher. 
 /// It also instantiates the HashSet collection to hold objects of type Discipline
 /// </summary>
 /// <param name="firstName">String value holding first name of the Teacher</param>
 /// <param name="lastName">String value holding last name of the Teacher</param>
 /// <param name="discipline">A discipline to be attached to Teacher instance.</param>
 public Teacher(string firstName, string lastName, Discipline discipline)
     : this(firstName, lastName)
 {
     this.AddDiscipline(discipline);
 }