コード例 #1
0
 public StudentCourseTask(CourseAttandee forStudent, Course inCourse, string TaskName, float TaskGrade)
 {
     ForStudent = forStudent;
     InCourse   = inCourse;
     Name       = TaskName;
     Grade      = TaskGrade;
 }
コード例 #2
0
ファイル: Academy.cs プロジェクト: krastiyan/KKrastevTasks
        public bool SignUp(CourseAttandee aStudent, Course toCourse)
        {
            if (aStudent == null)
            {
                throw new StudentNotFound("Student does not exist");
            }
            if (toCourse == null)
            {
                throw new CourseNotFound("Course does not exist");
            }
            try
            {
                aStudent.AttendedCourse = toCourse;
                toCourse.Attendees      = new List <CourseAttandee>()
                {
                    aStudent
                };
                Console.WriteLine($"Succesfully signed up {aStudent} to {toCourse}");
                return(true);
            }
            catch (StudentIsBusy e)
            {
                Console.WriteLine($"\n\tThrown an {e.GetType()} Exception saying: {e.Message}\n" + e.StackTrace);
            }
            catch (Exception e)
            {
                Console.WriteLine($"\t\tException! caught:\n{e.Message}\n" + e.StackTrace);
                if (e.Message.Contains("already full!") && aStudent.AttendedCourse != null)
                {
                    aStudent.AttendedCourse = null;
                }
            }

            return(false);
        }
コード例 #3
0
ファイル: Course.cs プロジェクト: krastiyan/KKrastevTasks
 public bool RemoveStudent(CourseAttandee student)
 {
     if (CheckAttending(student))
     {
         return(mAttendees.Remove(student));
     }
     return(false);
 }
コード例 #4
0
ファイル: Academy.cs プロジェクト: krastiyan/KKrastevTasks
 public bool UnSignUp(CourseAttandee aStudent, Course fromCourse)
 {
     if (fromCourse.CheckAttending(aStudent.Name))
     {
         fromCourse.RemoveStudent(aStudent);
         aStudent.AttendedCourse = null;
         Console.WriteLine($"Succesfully un-signed up {aStudent} from {fromCourse}");
         return(true);
     }
     Console.WriteLine($"'tINFO\t Student {aStudent} has not been currently signed up for course {fromCourse}\n");
     return(true);
 }
コード例 #5
0
ファイル: Course.cs プロジェクト: krastiyan/KKrastevTasks
 public bool CheckAttending(CourseAttandee studentToFind)
 {
     return(CheckAttending(studentToFind.Name));
 }