-
Notifications
You must be signed in to change notification settings - Fork 0
/
studygroup.py
63 lines (50 loc) · 1.75 KB
/
studygroup.py
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class StudyGroup:
def __init__(self, id = None):
self.id = id
self.students = []
self.courses = []
def get_id(self):
return self.id
def set_id(self, id):
self.id = id
def get_students(self):
for student in self.students:
return student.__str__()
def set_students(self, students):
self.students = students
def add_student(self, student):
if student:
if student in self.students:
print("This student is already in this group")
return False
else:
self.students.append(student)
self.courses.extend(student.courses)
else:
return True
def remove_student(self, student):
self.students.remove(student)
def num_student(self):
return len(self.students)
def get_courses(self):
course_list = []
for course in self.courses:
course_list.append((course.get_course_name()))
return course_list
def covered_courses(self):
covered_courses = []
for student in self.students:
for course in student.courses:
if course in self.courses:
continue
else:
self.courses.append(course)
covered_courses.append(course.get_course_name())
return covered_courses
def is_valid(self):
if len(self.students) <= 5:
return True
else:
return False
def __str__(self):
return '{} - covered courses: {}'.format(self.get_students(), self.covered_courses())