Example #1
0
 def add_section(section_info):
     info = section_info.split('/')
     for item in info:
         if item.endswith('R') or item.endswith('r'):
             self.recitation = Recitation(info)
         elif item.endswith('L') or item.endswith('l'):
             self.lab = Lab(info)
         else:
             self.lectures = Lecture(info)
Example #2
0
class Section(object):
    def __init__(self):
        self.lectures = 0
        self.recitation =0
        self.lab = 0

    def add_section(section_info):
        info = section_info.split('/')
        for item in info:
            if item.endswith('R') or item.endswith('r'):
                self.recitation = Recitation(info)
            elif item.endswith('L') or item.endswith('l'):
                self.lab = Lab(info)
            else:
                self.lectures = Lecture(info)

    def days_match(course_type_1, course_type_2):
        for i in range(0, len(course_type_1.days)):
            for j in range(0, len(course_type_2.days)):
                if course_type_1.days[i] == course_type_2.days[j]:
                    return True
        return False

    def check_times(course_type_1, course_type_2):
        if days_match(course_type_1, course_type_2) is False
            return True

        if course_type_1.begin_time < course_type_2.end_time:
            return False
        if course_type_2.begin_time < course_type_1.end_time:
            return False
        else:
            return True

    def conflicts_with(other_section):
        if check_times(self.lectures, other_section.lectures) is False:
            return False
        if check_times(self.lectures, other_section.recitation) is False:
            return False
        if check_times(self.lectures, other_section.lap) is False:
            return False

        if check_times(self.recitation, other_section.lectures) is False:
            return False
        if check_times(self.recitation, other_section.recitation) is False:
            return False
        if check_times(self.recitation, other_section.lap) is False:
            return False

        if check_times(self.lab, other_section.lectures) is False:
            return False
        if check_times(self.lab, other_section.recitation) is False:
            return False
        if check_times(self.lab, other_section.lap) is False:
            return False

    def print_section():
        if self.lectures != 0:
            self.lectures.print_info(),
            print "/",
        if self.recitation != 0
            self.recitation.print_info(),
            print "/",
        if self.lab != 0
            self.lab.print_info()