-
Notifications
You must be signed in to change notification settings - Fork 0
/
course.py
81 lines (64 loc) · 2.19 KB
/
course.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
class Course():
def __init__(self,course="",prof="",classroom="",type=""):
self.course = course
self.prof = prof
self.classroom = classroom
self.type = type
self.set_color()
@property
def course(self):
return self._course
@course.setter
def course(self,course):
if not course or course.isspace():
raise ValueError("Invalid course name ")
self._course = course
@property
def prof(self):
return self._prof
@prof.setter
def prof(self,prof):
if not prof or prof.isspace():
raise ValueError("Invalid professor name")
self._prof = prof
@property
def classroom(self):
return self._classroom
@classroom.setter
def classroom(self,classroom):
if not classroom or classroom.isspace():
raise ValueError("Invalid classroom")
self._classroom = classroom
@property
def type(self):
return self._type
@type.setter
def type(self,type):
if type not in ["C","TD","TP","CI"]:
raise ValueError("Invalid Course type")
self._type = type
@property
def color(self):
return self._color
@color.setter
def color(self,color):
if not color or color.isspace():
ValueError("Invalid color value")
self._color = color
def set_color(self):
if self._type == "C":
self._color = "FB6266"
elif self._type == "TD":
self._color = "80FF80"
elif self._type =="TP":
self._color = "7D7DFF"
elif self._type =="CI":
self._color = "868686"
else:
self._color = "F0F0F0"
def __eq__(self,other):
if isinstance(other,Course):
return self.course == other.course and self.prof == other.prof and self.classroom == other.classroom and self.type == other.type
return False
def __str__(self):
return f"course: {self.course} professor: {self.prof} classroom: {self.classroom} course type: {self.type}"