-
Notifications
You must be signed in to change notification settings - Fork 0
/
lesson.py
111 lines (90 loc) · 2.61 KB
/
lesson.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
"""
In this script the Lesson class is created in order to be used in the main script to evaluate possible outcomes for
graduation.
"""
class Lesson:
code = ''
credit = 0
year = 0 # Since in first year of METU you cannot take classes from upper years it is important.
prerequisites = []
semesters = [] # Semesters of lesson. Add 1 for Fall, 2 for Spring and 3 for Summer. No order needed.
grade = 'NG' # NG = Not Graded, the rest is as in the METU System.
def __init__(self, code, credit, year, prerequisites, semesters, grade='NG'):
"""
:param code: str
:param credit: int
:param year: int
:param prerequisites: list(str(code))
:param semesters: list(int)
:param grade: str(grade)
"""
self.code = code
self.credit = credit
self.year = year
self.prerequisites = prerequisites
self.semesters = semesters
self.grade = grade
def get_code(self):
"""
:return: str(code)
"""
return self.code
def update_grade(self, grade):
"""
:param grade: str(grade)
:return: None
"""
self.grade = grade
def is_passed(self):
"""
:return: bool
"""
if self.grade in ['AA', 'BA', 'BB', 'CB', 'CC', 'DC', 'DD', 'S', 'EX']:
return True
return False
def get_credits(self):
"""
:return: float
"""
if self.grade == 'AA':
return self.credit * 4.0
if self.grade == 'BA':
return self.credit * 3.5
if self.grade == 'BB':
return self.credit * 3.0
if self.grade == 'CB':
return self.credit * 2.5
if self.grade == 'CC':
return self.credit * 2.0
if self.grade == 'DC':
return self.credit * 1.5
if self.grade == 'DD':
return self.credit * 1.0
if self.grade == 'FD':
return self.credit * 0.5
return 0.0
def get_credit(self):
"""
:return: int
"""
return self.credit
def get_prerequisites(self):
"""
:return: list(str(code))
"""
return self.prerequisites
def get_semesters(self):
"""
:return: list(int) # integers are 1 for Fall, 2 for Spring and 3 for Summer.
"""
return self.semesters
def get_grade(self):
"""
:return: str
"""
return self.grade
def is_non_credit(self):
"""
:return: bool
"""
return not bool(self.credit)