-
Notifications
You must be signed in to change notification settings - Fork 0
/
student.py
31 lines (27 loc) · 1.1 KB
/
student.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
class Student:
"""Common base class for all students"""
numReg = []
# basic init method for Student class
def __init__(self, number, name, family, courses=None):
if courses is None:
courses = []
self.number = number
self.numReg.append(self)
self.name = name
self.family = family
self.courses = courses
# when called, it will display student's name anf family
def displayStudent(self):
print('You are logged in as ' + self.name + ' ' + self.family)
# when called, it'll display the courses a student has
def displayStudentCourses(self, numStudent):
if self.number == numStudent:
if self.courses:
print(self.courses)
else:
print('You have no courses, yet!')
# when called, it will add the "wantedCourse" to the "numStudent" courses
def studentCourseAdding(self, wantedCourse, numStudent):
if self.number == numStudent:
self.courses.append(wantedCourse)
print('You Added ' + wantedCourse + ' to your schedule, successfully!')