-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule.py
128 lines (85 loc) · 3.27 KB
/
module.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
from moduleElement import *
class Module(object):
module_count = 0
def __init__(self,ects,title,semester,grade=None):
"constructor for class module"
self.ects = ects
self.grade = grade
self.title = title
self.semester = semester
self.dates = []
self.elements = []
Module.module_count += 1
def get_important_dates_overview(self):
"prints all the important dates for a module"
print("Important dates for {0:s}:".format(self.title))
for kind,date in self.dates:
print("\t{0:s} on {1:s}".format(kind,date))
def set_grade(self,grade):
"set the grade to a given value"
self.grade = grade
def add_module_element(self,other_class,date):
"add a new module element to the elements list"
obj = other_class(self)
obj.add_important_date(date)
self.elements.append((obj))
def get_title(self):
return self.title
def get_grade(self):
return self.grade
#########################################################################
class Course(Module):
def __str__(self):
return 'Course: {}'.format(self.title)
#########################################################################
class Seminar(Module):
def __init__(self,ects,title,semester,topic):
Module.__init__(self, ects, title, semester)
self.__topic = topic
def __str__(self):
return '{} under the topic: {}'.format(self.title, self.__topic)
def get_topic(self):
return self.__topic
#########################################################################
class Thesis(Module):
def __init__(self,ects,title,semester,topic,research_group):
Module.__init__(self, ects, title, semester)
self.__topic = topic
self.__research_group = research_group
def __str__(self):
return '{} on the topic: {} in the Research Group {}'.format(self.title, self.__topic, \
self.__research_group)
def get_topic(self):
return self.__topic
def get_research_group(self):
return self.__research_group
#########################################################################
### test cases ###
info1 = Course(6,"Info 1",1)
info1.add_module_element(Midterm,"31.10.2017")
info1.add_module_element(FinalExam,"20.12.2017")
info1.get_important_dates_overview()
print(info1)
# expected output:
# Course: Info 1
math1 = Course(6, "Mathematik I", 1)
math1.add_module_element(Midterm,"18.12.2017")
math1.get_important_dates_overview()
# expected output:
# Important dates for Info 1:
# Midterm on 31.10.2017
# Final Exam on 20.12.2017
# Important dates for Mathematik I:
# Midterm on 18.12.2017
print(Module.module_count)
# expected output: 2
thesis = Thesis(18,"Bachelor Thesis",6,"A promising research topic on Software Engineering","SEAL")
print(thesis)
# expected output:
# Bachelor Thesison the topic: A promising research topic on Software Engineering in the Research Group SEAL
sem = Seminar(3,"Seminar in Software Engineering",4,"A Seminar topic")
print(sem)
print(thesis)
# expected output:
# Seminar in Software Engineering under the topic: A Seminar topic
info1.set_grade(6)