protected override void addSemesterButton_Click(object sender, EventArgs e) { //variables int year; TermEnums term; int minCredits; int maxCredits; Semester editedSemester; try { //attempt to parse text boxes year = parseYear(yearTB.Text); term = parseTerm(termTB.Text); verifyCredits(minCreditsTB.Text, maxCreditsTB.Text, out minCredits, out maxCredits); //attempt to create Semester object editedSemester = new Semester(year, term); editedSemester.MaxCredits = maxCredits; editedSemester.MinCredits = minCredits; editedSemester.IsOverloadable = overloadableCB.Checked; //check that the semester does not already exist, if reference change if (!editedSemester.Equals(editSemester)) { if (semesterList.Contains(editedSemester)) { throw new Exception("The Semester already exists!"); } } //replace edited semester object semesterList.Remove(editSemester); semesterList.Add(editedSemester); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }