File size: 816 Bytes
8e7d8ae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Stores data about student group
class StudentsGroup:
    # Initializes student group data
    def __init__(self, id, numberOfStudents):
        self.Id = id
        # self.Name = name
        self.NumberOfStudents = numberOfStudents
        self.CourseClasses = []

    # Bind group to class
    def addClass(self, course_class):
        self.CourseClasses.append(course_class)

    def __hash__(self):
        return hash(self.Id)

    # Compares ID's of two objects which represent student groups
    def __eq__(self, other):
        if not isinstance(other, self.__class__):
            return False
        return hash(self) == hash(other)

    def __ne__(self, other):
        # Not strictly necessary, but to avoid having both x==y and x!=y
        # True at the same time
        return not (self == other)