-
Notifications
You must be signed in to change notification settings - Fork 0
/
professor.py
38 lines (34 loc) · 1.49 KB
/
professor.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
from course import Course
class Professor:
"""common base class for all professors"""
numReg = []
# basic init method for Course class
def __init__(self, number, family, profCourses=None):
if profCourses is None:
profCourses = []
self.number = number
self.numReg.append(self)
self.family = family
self.profCourses = profCourses
# when called, the professor family and instructed courses will be shown
def displayProfessor(self, numProfessor):
if self.number == numProfessor:
print('Welcome Dear Dr.' + self.family)
print('You are the instructor of %d course(s) ' % len(self.profCourses))
# when called, new course will be added to the profCourses list
@staticmethod
def professorCourseGiving(newCourseOption, numProfessor):
for k in Course.numReg:
if k.number == newCourseOption:
courseProf = k.profOfCourse
if courseProf:
print('Sorry Sir! Another professor has instructed this course, before!')
else:
for k in Course.numReg:
if k.number == newCourseOption:
for j in Professor.numReg:
if j.number == numProfessor:
j.profCourses.append(k.name)
k.profOfCourse = j.family
courseList = [k.name for k in Course.numReg]
print('You are now the instructor of %s!' % courseList[newCourseOption-1])