Exemplo n.º 1
0
        // Set a grade for a currently enrolled applicant
        public void EnterMark(Applicant applicant, int mark)
        {
            // Check for errors before entering a grade
            // Applicant may have already passed exam or not be enrolled on it

            if (GradeArchive.ContainsKey(applicant) == true) //passed, so not currrently enrolled
            {
                AlreadyPassedException apException = new AlreadyPassedException(applicant.RegNo);
                throw (apException);
            }
            else if (EnrolledApplicants.ContainsKey(applicant.RegNo) == false) //not currently enrolled
            {
                NotEnrolledException neException = new NotEnrolledException(applicant.RegNo);
                throw (neException);
            }
            else
            {
                // Add Applicant to the Dictionary
                EnrolledApplicants.Add(applicant.RegNo, applicant);

                // Get the Applicant to add this ForceService to its 'enrolled' List
                applicant.AddForceService(this);


                ResultInput ri = new ResultInput(this, applicant, mark);

                // If applicant has passed the exam
                if (mark >= AppData.PASSMARK)
                {
                    // Add the ResultInput and its associated Applicant
                    // to the GradeArchive dictionary.
                    GradeArchive.Add(applicant, ri);

                    // Remove Applicant from the currentlyEnrolled dictionary
                    EnrolledApplicants.Remove(applicant.RegNo);

                    // Get the Applicant to remove Exam/ForceService course from its 'enrolled' list
                    applicant.DropForceService(this);
                }
            }
        }
Exemplo n.º 2
0
 // Unenrol an applicant for a military force
 public void Unenrol(Applicant applicant)
 {
     // check for applicant enrolment
     if (GradeArchive.ContainsKey(applicant) == true) // passed
     {
         AlreadyPassedException apException = new AlreadyPassedException(applicant.RegNo);
         throw (apException);
     }
     else if (EnrolledApplicants.ContainsKey(applicant.RegNo) == false) // not currently enrolled
     {
         NotEnrolledException neException = new NotEnrolledException(applicant.RegNo);
         throw (neException);
     }
     else
     {
         // Remove Student from currentlyEnrolled dictionary
         EnrolledApplicants.Remove(applicant.RegNo);
         // Get the Applicant to remove Service from its 'enrolled' list
         applicant.DropForceService(this);
     }
 }