-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobjects.py
53 lines (37 loc) · 1.23 KB
/
objects.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
class Transcript:
def __init__(self):
self.subjects = []
def add_subject(self, subject):
self.subjects.append(subject)
def get_wam(self):
total_credits = 0
total_marks = 0
for each in self.subjects:
total_credits += each.get_credit_points()
total_marks += each.get_mark() * each.get_credit_points()
if total_credits == 0:
return 0
wam = total_marks / total_credits
return wam
def print_transcript(self):
print("Year\tSession\tCode\tName\t Mark\tCPs")
for each in self.subjects:
print("\t".join([each.year, each.session, each.unit_code, each.name, each.mark, each.credit_points]))
def __str__(self):
pass
class Subject:
def __init__(self, year, session, code, name, mark, credit_points):
self.unit_code = code
self.name = name
self.department = code[:4]
self.level = code[4]
self.year = year
self.session = session
self.credit_points = credit_points
self.mark = mark
def get_credit_points(self):
return self.credit_points
def get_mark(self):
return self.mark
def __str__(self):
pass