public Section(int crn, ClassTime lecture) //this constructor is used when there is just a lecture { this.crn = crn; this.lecture = lecture; this.classTimes = new List <ClassTime>() { lecture }; //LabRec is not added to ClassTimes list to avoid NullException during testing }
public Section(int crn, ClassTime lecture, ClassTime labRec) //this constructor is used when the section contains a lab or recitation { this.crn = crn; this.lecture = lecture; this.labRec = labRec; this.classTimes = new List <ClassTime>() { { lecture }, { labRec } }; }
//METHODS public bool OnSameDay(ClassTime AClass) { foreach (char chr in this.days) //test all chars in the days shorthand { if (AClass.Days.Contains(chr)) { return(true); //if AClass and this have any day(s) in common } } return(false); //if it passes the entire foreach loop, then AClass and this have no days in common }
public bool HasTimeConflict(ClassTime AClass) { if ((AClass.StartTime.TimeOfDay >= this.startTime.TimeOfDay) && (AClass.StartTime.TimeOfDay <= this.endTime.TimeOfDay)) { return(true); //if the start time for AClass is in between the start and end times for this, then there is a time conflict } else if ((AClass.EndTime.TimeOfDay >= this.startTime.TimeOfDay) && (AClass.EndTime.TimeOfDay <= this.endTime.TimeOfDay)) { return(true); //if the end time for AClass is in between the start and end times for this, then there is a time conflict } else { return(false); //only if the start and end times don't conflict is there no time conflict } }