/// <summary> /// Adds a student to the group /// </summary> /// <param name="student">the student to add</param> /// <returns>false if the student already exists in the group</returns> public bool AddStudent(Student student) { if (mGroupMembers != null) { if (mGroupMembers.Contains(student) == true) { //TODO: Add a message box pointing out the error return false; } else { mGroupMembers.Add(student); return true; } } return false; }
/// <summary> /// Parses a string that is used to initialize a new Student object /// </summary> /// <param name="message">the message to be split and used to instantialize a new student</param> /// <returns>the student created from the message</returns> public Student CreateStudentFromString(string message) { string FirstName = message.Substring(0, message.IndexOf("/")); message = message.Remove(0, message.IndexOf("/") + 1); string LastName = message.Substring(0, message.IndexOf("/")); message = message.Remove(0, message.IndexOf("/") + 1); string UserName = message.Substring(0, message.IndexOf("/")); message = message.Remove(0, message.IndexOf("/") + 1); string FirstChoice = message.Substring(0, message.IndexOf("/")); message = message.Remove(0, message.IndexOf("/") + 1); Job Primary = JobFromString(FirstChoice); string SecondChoice = message.Substring(0, message.IndexOf("/")); message = message.Remove(0, message.IndexOf("/") + 1); Job Seconday = JobFromString(SecondChoice); string ThirdChoice = message.Substring(0, message.Length); Job Tertiary = JobFromString(ThirdChoice); if (Primary == Job.NoJob) { Primary = Job.WildCard; } if (Seconday == Job.NoJob) { Seconday = Job.WildCard; } if (Tertiary == Job.NoJob) { Tertiary = Job.WildCard; } Student NewStudent = new Student(LastName, FirstName, UserName, Primary, Seconday, Tertiary); return NewStudent; }
/// <summary> /// Adds a student to the class list /// </summary> /// <param name="student">the student to add</param> /// <returns>returns false if the student already exists in the class list</returns> public bool AddStudent(Student student) { if (mClassList != null) { if (mClassList.ContainsKey(student.EmailID) == true) { MessageBox.Show("Student already added to the class list", "Information"); return false; } else { mClassList.Add(student.EmailID, student); mNumberOfStudents++; return true; } } return false; }