public bool HasConflict(TimeSlot otherTimeSlot) { if (this.day != otherTimeSlot.day) { return false; } else { //partially overlap (first case) if (this.start < otherTimeSlot.start && this.end > otherTimeSlot.start) { return true; } //partially overlap (second case) if (this.start < otherTimeSlot.end && this.end > otherTimeSlot.end) { return true; } //fully overlap (inclusive) (fist case) if (this.start > otherTimeSlot.start && this.end < otherTimeSlot.end) { return true; } //fully overlap (inclusive) (second case) if (this.start < otherTimeSlot.start && this.end > otherTimeSlot.end) { return true; } return false; } }
private static void TimeSlotConflitTest() { TimeSlot t1 = new TimeSlot(1, 9, 10); TimeSlot t2 = new TimeSlot(2, 9, 10); Console.WriteLine(t1.HasConflict(t2).ToString()); TimeSlot t3 = new TimeSlot(1, 9, 10.5); TimeSlot t4 = new TimeSlot(1, 10, 14); Console.WriteLine(t3.HasConflict(t4).ToString()); TimeSlot t5 = new TimeSlot(1, 10, 14); TimeSlot t6 = new TimeSlot(1, 9, 10.5); Console.WriteLine(t5.HasConflict(t6).ToString()); TimeSlot t7 = new TimeSlot(1, 10, 11); TimeSlot t8 = new TimeSlot(1, 9, 13); Console.WriteLine(t7.HasConflict(t8).ToString()); TimeSlot t9 = new TimeSlot(1, 10, 11); TimeSlot t10 = new TimeSlot(1, 13, 15); Console.WriteLine(t9.HasConflict(t10).ToString()); }
public SectionInfo(TimeSlot timeSlot, string Location, string Instructor) { this.timeSlot = timeSlot; this.Location = Location; this.Instructor = Instructor; }